config

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigDirName = "mongui"
)

Variables

This section is empty.

Functions

func GetConfigDir

func GetConfigDir() (string, error)

GetConfigDir returns the path to the config directory

func GetConfigPath

func GetConfigPath() (string, error)

GetConfigPath returns the path to the config file

func ParseMongoDBURI

func ParseMongoDBURI(uri string) (host, port, db string, err error)

Types

type AutocompleteStyle

type AutocompleteStyle struct {
	BackgroundColor       Style `yaml:"backgroundColor"`
	BorderColor           Style `yaml:"borderColor"`
	TextColor             Style `yaml:"textColor"`
	ActiveBackgroundColor Style `yaml:"activeBackgroundColor"`
	ActiveTextColor       Style `yaml:"activeTextColor"`
	SecondaryTextColor    Style `yaml:"secondaryTextColor"`
}

Styles is a struct that contains all the styles for the application

type Config

type Config struct {
	Log                LogConfig     `yaml:"log"`
	Debug              bool          `yaml:"debug"`
	Editor             EditorConfig  `yaml:"editor"`
	ShowConnectionPage bool          `yaml:"showConnectionPage"`
	ShowWelcomePage    bool          `yaml:"showWelcomePage"`
	CurrentConnection  string        `yaml:"currentConnection"`
	Connections        []MongoConfig `yaml:"connections"`
}

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig loads the config file If the file does not exist, it will be created with the default settings

func (*Config) AddConnection

func (c *Config) AddConnection(mongoConfig *MongoConfig) error

AddConnection adds a MongoDB connection to the config file

func (*Config) AddConnectionFromUri

func (c *Config) AddConnectionFromUri(mongoConfig *MongoConfig) error

AddConnectionFromUri adds a MongoDB connection to the config file using a URI

func (*Config) DeleteConnection

func (c *Config) DeleteConnection(name string) error

DeleteConnection deletes a config from the config file by name

func (*Config) GetCurrentConnection

func (c *Config) GetCurrentConnection() *MongoConfig

GetCurrentConnection gets the current connection from the config file

func (*Config) GetEditorCmd

func (c *Config) GetEditorCmd() (string, error)

GetEditorCmd returns the editor command from the config file

func (*Config) SetCurrentConnection

func (c *Config) SetCurrentConnection(name string) error

SetCurrentConnection sets the current connection in the config file

func (*Config) UpdateConfig

func (c *Config) UpdateConfig() error

UpdateConfig updates the config file with the new settings

type ConnectorFormKeys

type ConnectorFormKeys struct {
	FormFocusUp    Key `json:"formFocusUp"`
	FormFocusDown  Key `json:"formFocusDown"`
	SaveConnection Key `json:"saveConnection"`
	FocusList      Key `json:"focusList"`
}

type ConnectorKeys

type ConnectorKeys struct {
	ConnectorForm ConnectorFormKeys `json:"connectorForm"`
	ConnectorList ConnectorListKeys `json:"connectorList"`
}

type ConnectorListKeys

type ConnectorListKeys struct {
	FocusForm        Key `json:"focusForm"`
	DeleteConnection Key `json:"deleteConnection"`
	SetConnection    Key `json:"setConnection"`
}

type ConnectorStyle

type ConnectorStyle struct {
	BackgroundColor              Style `yaml:"backgroundColor"`
	BorderColor                  Style `yaml:"borderColor"`
	TitleColor                   Style `yaml:"titleColor"`
	FormLabelColor               Style `yaml:"formLabelColor"`
	FormInputBackgroundColor     Style `yaml:"formInputBackgroundColor"`
	FormInputColor               Style `yaml:"formInputColor"`
	FormButtonColor              Style `yaml:"formButtonColor"`
	ListTextColor                Style `yaml:"listTextColor"`
	ListSelectedTextColor        Style `yaml:"listSelectedTextColor"`
	ListSelectedBackgroundColor  Style `yaml:"listSelectedBackgroundColor"`
	ListSecondaryTextColor       Style `yaml:"listSecondaryTextColor"`
	ListSecondaryBackgroundColor Style `yaml:"listSecondaryBackgroundColor"`
}

ConnectorStyle is a struct that contains all the styles for the connector

type ContentKeys

type ContentKeys struct {
	PeekDocument      Key      `json:"peekDocument"`
	ViewDocument      Key      `json:"viewDocument"`
	AddDocument       Key      `json:"addDocument"`
	EditDocument      Key      `json:"editDocument"`
	DuplicateDocument Key      `json:"duplicateDocument"`
	DeleteDocument    Key      `json:"deleteDocument"`
	Refresh           Key      `json:"refresh"`
	ToggleQuery       Key      `json:"toggleQuery"`
	NextPage          Key      `json:"nextPage"`
	PreviousPage      Key      `json:"previousPage"`
	QueryBar          QueryBar `json:"queryBar"`
}

type ContentStyle

type ContentStyle struct {
	BackgroundColor  Style `yaml:"backgroundColor"`
	BorderColor      Style `yaml:"borderColor"`
	TitleColor       Style `yaml:"titleColor"`
	CellTextColor    Style `yaml:"cellTextColor"`
	ActiveRowColor   Style `yaml:"activeRowColor"`
	SelectedRowColor Style `yaml:"selectedRowColor"`
}

ContentStyle is a struct that contains all the styles for the content

type DatabasesKeys

type DatabasesKeys struct {
	FilterBar        Key `json:"filterBar"`
	ExpandAll        Key `json:"expandAll"`
	CollapseAll      Key `json:"collapseAll"`
	ToggleExpand     Key `json:"toggleExpand"`
	AddCollection    Key `json:"addCollection"`
	DeleteCollection Key `json:"deleteCollection"`
}

type DatabasesStyle

type DatabasesStyle struct {
	BackgroundColor Style `yaml:"backgroundColor"`
	BorderColor     Style `yaml:"borderColor"`
	TitleColor      Style `yaml:"titleColor"`
	NodeColor       Style `yaml:"nodeColor"`
	NodeSymbol      Style `yaml:"nodeSymbol"`
	LeafColor       Style `yaml:"leafColor"`
	LeafSymbol      Style `yaml:"leafSymbol"`
	BranchColor     Style `yaml:"branchColor"`
}

DatabasesStyle is a struct that contains all the styles for the databases

type DocPeekerStyle

type DocPeekerStyle struct {
	BackgroundColor Style `yaml:"backgroundColor"`
	BorderColor     Style `yaml:"borderColor"`
	TitleColor      Style `yaml:"titleColor"`
	KeyColor        Style `yaml:"keyColor"`
	ValueColor      Style `yaml:"valueColor"`
	BracketColor    Style `yaml:"bracketColor"`
}

DocPeekerStyle is a struct that contains all the styles for the json peeker

type EditorConfig

type EditorConfig struct {
	Command string `yaml:"command"`
	Env     string `yaml:"env"`
}

type GlobalKeys

type GlobalKeys struct {
	ToggleFullScreenHelp Key `json:"toggleFullScreenHelp"`
	ToggleHelpBarFooter  Key `json:"toggleHelpBarFooter"`
}

GlobalKeys is a struct that holds the global keybindings for the application, they can be triggered from any component as keys are passed from top to bottom

type HeaderStyle

type HeaderStyle struct {
	BackgroundColor Style `yaml:"backgroundColor"`
	BorderColor     Style `yaml:"borderColor"`
	TitleColor      Style `yaml:"titleColor"`
	KeyColor        Style `yaml:"keyColor"`
	ValueColor      Style `yaml:"valueColor"`
	ActiveSymbol    Style `yaml:"activeSymbol"`
	InactiveSymbol  Style `yaml:"inactiveSymbol"`
}

HeaderStyle is a struct that contains all the styles for the header

type HelpKeys

type HelpKeys struct {
	Close Key `json:"close"`
}

type HelpStyle

type HelpStyle struct {
	BackgroundColor  Style `yaml:"backgroundColor"`
	BorderColor      Style `yaml:"borderColor"`
	TitleColor       Style `yaml:"titleColor"`
	KeyColor         Style `yaml:"keyColor"`
	DescriptionColor Style `yaml:"descriptionColor"`
}

Styles is a struct that contains all the styles for the application

type HistoryStyle

type HistoryStyle struct {
	BackgroundColor         Style `yaml:"backgroundColor"`
	TextColor               Style `yaml:"textColor"`
	SelectedTextColor       Style `yaml:"selectedTextColor"`
	SelectedBackgroundColor Style `yaml:"selectedBackgroundColor"`
}

Styles is a struct that contains all the styles for the application

type InputBarStyle

type InputBarStyle struct {
	BackgroundColor Style             `yaml:"backgroundColor"`
	BorderColor     Style             `yaml:"borderColor"`
	TitleColor      Style             `yaml:"titleColor"`
	LabelColor      Style             `yaml:"labelColor"`
	InputColor      Style             `yaml:"inputColor"`
	Autocomplete    AutocompleteStyle `yaml:"autocomplete"`
}

InputBarStyle is a struct that contains all the styles for the filter bar

type Key

type Key struct {
	Keys        []string `json:"keys,omitempty"`
	Runes       []string `json:"runes,omitempty"`
	Description string   `json:"description"`
}

Key is a lowest level of keybindings It holds the keys and runes that are used to trigger the action and a description of the action that will be displayed in the help

type KeyBindings

type KeyBindings struct {
	Global    GlobalKeys    `json:"global"`
	Root      RootKeys      `json:"root"`
	Connector ConnectorKeys `json:"connector"`
	Help      HelpKeys      `json:"help"`
}

KeyBindings is a way to define keybindings for the application There are components that have only keybindings and some have nested keybindings of their children components

func LoadKeybindings

func LoadKeybindings() (*KeyBindings, error)

LoadKeybindings loads keybindings from the config file if the file does not exist it creates a new one with default keybindings

func (*KeyBindings) Contains

func (kb *KeyBindings) Contains(configKey Key, namedKey string) bool

Contains checks if the keybindings contains the key

func (*KeyBindings) ConvertStrKeyToTcellKey

func (kb *KeyBindings) ConvertStrKeyToTcellKey(key string) (tcell.Key, bool)

ConvertStrKeyToTcellKey converts string key to tcell key

func (KeyBindings) GetKeysForComponent

func (kb KeyBindings) GetKeysForComponent(component string) ([]OrderedKeys, error)

GetKeysForComponent returns keys for component

type LogConfig

type LogConfig struct {
	Path        string `yaml:"path"`
	Level       string `yaml:"level"`
	PrettyPrint bool   `yaml:"prettyPrint"`
}

type MongoConfig

type MongoConfig struct {
	Uri      string `yaml:"url"`
	Host     string `yaml:"host"`
	Port     int    `yaml:"port"`
	Database string `yaml:"database"`
	Username string `yaml:"username"`
	Password string `yaml:"password"`
	Name     string `yaml:"name"`
	Timeout  int    `yaml:"timeout"`
}

func (*MongoConfig) GetUri

func (m *MongoConfig) GetUri() string

type OrderedKeys

type OrderedKeys struct {
	Component string
	Keys      []Key
}

type OthersStyle

type OthersStyle struct {
	ButtonsTextColor       Style `yaml:"buttonsTextColor"`
	ButtonsBackgroundColor Style `yaml:"buttonsBackgroundColor"`
}

Styles is a struct that contains all the styles for the application

type QueryBar

type QueryBar struct {
	ShowHistory Key `json:"showHistory"`
	ClearInput  Key `json:"clearInput"`
}

type RootKeys

type RootKeys struct {
	FocusNext     Key           `json:"focusNext"`
	HideDatabases Key           `json:"hideDatabases"`
	OpenConnector Key           `json:"openConnector"`
	Databases     DatabasesKeys `json:"databases"`
	Content       ContentKeys   `json:"content"`
}

type RootStyle

type RootStyle struct {
	BackgroundColor    Style `yaml:"backgroundColor"`
	TextColor          Style `yaml:"textColor"`
	SecondaryTextColor Style `yaml:"secondaryTextColor"`
	BorderColor        Style `yaml:"borderColor"`
	FocusColor         Style `yaml:"focusColor"`
	TitleColor         Style `yaml:"titleColor"`
	GraphicsColor      Style `yaml:"graphicsColor"`
}

RootStyle is a struct that contains all the root styles for the application

type Style

type Style string

Styles is a struct that contains all the styles for the application

func (*Style) Color

func (s *Style) Color() tcell.Color

Color returns the tcell.Color of the style

func (*Style) String

func (s *Style) String() string

String returns the string value of the style

type Styles

type Styles struct {
	Root      RootStyle      `yaml:"main"`
	Welcome   WelcomeStyle   `yaml:"welcome"`
	Connector ConnectorStyle `yaml:"connector"`
	Header    HeaderStyle    `yaml:"header"`
	Databases DatabasesStyle `yaml:"databases"`
	Content   ContentStyle   `yaml:"content"`
	DocPeeker DocPeekerStyle `yaml:"docPeeker"`
	InputBar  InputBarStyle  `yaml:"filterBar"`
	History   HistoryStyle   `yaml:"history"`
	Help      HelpStyle      `yaml:"help"`
	Others    OthersStyle    `yaml:"others"`
}

Styles is a struct that contains all the styles for the application

func LoadStyles

func LoadStyles() (*Styles, error)

LoadStyles creates a new Styles struct with default values

type WelcomeStyle

type WelcomeStyle struct {
	BackgroundColor          Style `yaml:"backgroundColor"`
	TextColor                Style `yaml:"textColor"`
	FormLabelColor           Style `yaml:"formLabelColor"`
	FormInputColor           Style `yaml:"formInputColor"`
	FormInputBackgroundColor Style `yaml:"formInputBackgroundColor"`
}

WelcomeStyle is a struct that contains all the styles for the welcome screen

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL