Documentation
¶
Overview ¶
Package config provides functionality to read environment variables, runtime arguments, and configuration files.
Index ¶
- Variables
- func DecryptPassword(encryptedPassword string) (string, error)
- func DefaultColorSchemes() map[string]*ColorScheme
- func EncryptPassword(password string) (string, error)
- func GetTcellColor(colorName string) tcell.Color
- func IsEncrypted(password string) bool
- type Argument
- type ColorConfig
- type ColorScheme
- type DBConfig
- type DBConfigFile
- type DBConnection
- type DBMS
- type DBMSType
- type HistoryDB
- type MemoryDB
- type MySQLConfig
- type MySQLDB
- type PostgreSQLConfig
- type PostgreSQLDB
- type SQLServerConfig
- type SQLServerDB
- type SQLite3Config
- type SQLite3DB
Constants ¶
This section is empty.
Variables ¶
var Set = wire.NewSet( NewMemoryDB, NewDBConfig, NewColorManager, NewHistoryDB, )
Set is config providers.
var ( // Version is sqluv command version. Version value is assigned by LDFLAGS. Version string )
Functions ¶
func DecryptPassword ¶ added in v0.1.0
DecryptPassword decrypts an encrypted password string
func DefaultColorSchemes ¶ added in v0.1.5
func DefaultColorSchemes() map[string]*ColorScheme
DefaultColorSchemes returns the default color schemes
func EncryptPassword ¶ added in v0.1.0
EncryptPassword encrypts a password string using AES-GCM
func GetTcellColor ¶ added in v0.1.5
func GetTcellColor(colorName string) tcell.Color
GetTcellColor converts a color string to a tcell.Color
func IsEncrypted ¶ added in v0.1.0
IsEncrypted checks if a password string is likely encrypted
Types ¶
type Argument ¶
type Argument struct {
// contains filtered or unexported fields
}
Argument represents a runtime argument.
func NewArgument ¶
NewArgument creates a new Argument instance.
func (*Argument) CanVersion ¶
CanVersion returns true if sqluv command can show version message.
type ColorConfig ¶ added in v0.1.5
type ColorConfig struct { CurrentScheme *ColorScheme Schemes map[string]*ColorScheme // contains filtered or unexported fields }
ColorConfig manages the application color schemes
func NewColorManager ¶ added in v0.1.5
func NewColorManager() (*ColorConfig, error)
NewColorManager creates a new color manager
func (*ColorConfig) GetSchemeNames ¶ added in v0.1.5
func (cm *ColorConfig) GetSchemeNames() []string
GetSchemeNames returns the names of all available color schemes
func (*ColorConfig) SaveCurrentScheme ¶ added in v0.1.5
func (cm *ColorConfig) SaveCurrentScheme() error
SaveCurrentScheme saves the current color scheme to the configuration file
func (*ColorConfig) SetScheme ¶ added in v0.1.5
func (cm *ColorConfig) SetScheme(name string) error
SetScheme sets the current color scheme
type ColorScheme ¶ added in v0.1.5
type ColorScheme struct { Name string `yaml:"name"` Background string `yaml:"background"` Foreground string `yaml:"foreground"` Border string `yaml:"border"` BorderFocus string `yaml:"border_focus"` Selection string `yaml:"selection"` SelectionText string `yaml:"selection_text"` Header string `yaml:"header"` Button string `yaml:"button"` ButtonFocus string `yaml:"button_focus"` ButtonText string `yaml:"button_text"` ButtonTextFocus string `yaml:"button_text_focus"` }
ColorScheme represents a complete color scheme for the TUI
type DBConfig ¶ added in v0.1.0
type DBConfig struct {
// contains filtered or unexported fields
}
DBConfig manages database configurations
func NewDBConfig ¶ added in v0.1.0
NewDBConfig creates a new database configuration manager
func (*DBConfig) GetConnectionByName ¶ added in v0.1.0
func (cm *DBConfig) GetConnectionByName(name string) (DBConnection, error)
GetConnectionByName retrieves a specific connection by name
func (*DBConfig) LoadConnections ¶ added in v0.1.0
func (cm *DBConfig) LoadConnections() ([]DBConnection, error)
LoadConnections loads all database connections from the config file
func (*DBConfig) RemoveConnection ¶ added in v0.1.0
RemoveConnection removes a database connection from the config file by name
func (*DBConfig) SaveConnection ¶ added in v0.1.0
func (cm *DBConfig) SaveConnection(conn DBConnection) error
SaveConnection saves a database connection to the config file
type DBConfigFile ¶ added in v0.1.0
type DBConfigFile struct {
Connections []DBConnection `yaml:"connections"`
}
DBConfigFile represents the structure of the dbms.yml file
type DBConnection ¶ added in v0.1.0
type DBConnection struct { Name string `yaml:"name"` Type DBMSType `yaml:"type"` Host string `yaml:"host"` Port int `yaml:"port"` User string `yaml:"user"` Password string `yaml:"password"` Database string `yaml:"database"` }
DBConnection represents a database connection configuration as a value object
type DBMSType ¶ added in v0.1.0
type DBMSType string
DBMSType represents the type of DBMS
const ( // MySQL represents the MySQL DBMS MySQL DBMSType = "MySQL" // PostgreSQL represents the PostgreSQL DBMS PostgreSQL DBMSType = "PostgreSQL" // SQLite3 represents the SQLite3 DBMS SQLite3 DBMSType = "SQLite3" // SQLServer represents the Microsoft SQL Server DBMS SQLServer DBMSType = "SQLServer" // Oracle represents the Oracle Database Oracle DBMSType = "Oracle" )
type HistoryDB ¶ added in v0.1.3
HistoryDB is *sql.DB for sqly shell history.
func NewHistoryDB ¶ added in v0.1.3
NewHistoryDB create *sql.DB for history. The return function is the function to close the DB.
type MemoryDB ¶
MemoryDB is *sql.DB for excuting sql.
func NewMemoryDB ¶
NewMemoryDB create *sql.DB for SQLite3. SQLite3 store data in memory. The return function is the function to close the DB.
type MySQLConfig ¶ added in v0.1.0
type MySQLConfig struct {
// contains filtered or unexported fields
}
MySQLConfig holds the configuration for MySQL connection.
func NewMySQLConfig ¶ added in v0.1.0
func NewMySQLConfig( host string, port int, user string, password string, database string, ) MySQLConfig
NewMySQLConfig creates MySQLConfig.
type MySQLDB ¶ added in v0.1.0
type MySQLDB = DBMS
MySQLDB is *sql.DB for executing SQL with MySQL.
func NewMySQLDB ¶ added in v0.1.0
func NewMySQLDB(config MySQLConfig) (MySQLDB, func(), error)
NewMySQLDB creates *sql.DB for MySQL. The return function is the function to close the DB.
type PostgreSQLConfig ¶ added in v0.1.0
type PostgreSQLConfig struct {
// contains filtered or unexported fields
}
PostgreSQLConfig holds the configuration for PostgreSQL connection.
func NewPostgreSQLConfig ¶ added in v0.1.0
func NewPostgreSQLConfig( host string, port int, user string, password string, database string, ) PostgreSQLConfig
NewPostgreSQLConfig creates PostgreSQLConfig.
type PostgreSQLDB ¶ added in v0.1.0
type PostgreSQLDB = DBMS
PostgreSQLDB is *sql.DB for executing SQL with PostgreSQL
func NewPostgreSQLDB ¶ added in v0.1.0
func NewPostgreSQLDB(config PostgreSQLConfig) (PostgreSQLDB, func(), error)
NewPostgreSQLDB creates *sql.DB for PostgreSQL. The return function is the function to close the DB.
type SQLServerConfig ¶ added in v0.1.1
type SQLServerConfig struct {
// contains filtered or unexported fields
}
SQLServerConfig holds the configuration for SQL Server connection.
func NewSQLServerConfig ¶ added in v0.1.1
func NewSQLServerConfig( host string, port int, user string, password string, database string, ) SQLServerConfig
NewSQLServerConfig creates SQLServerConfig.
type SQLServerDB ¶ added in v0.1.1
type SQLServerDB = DBMS
SQLServerDB is *sql.DB for executing SQL with SQL Server.
func NewSQLServerDB ¶ added in v0.1.1
func NewSQLServerDB(config SQLServerConfig) (SQLServerDB, func(), error)
NewSQLServerDB creates *sql.DB for SQL Server. The return function is the function to close the DB.
type SQLite3Config ¶ added in v0.1.1
type SQLite3Config struct {
// contains filtered or unexported fields
}
SQLite3Config holds the configuration for SQLite3 connection.
func NewSQLite3Config ¶ added in v0.1.1
func NewSQLite3Config(filepath string) SQLite3Config
NewSQLite3Config creates SQLite3Config.
type SQLite3DB ¶ added in v0.1.1
type SQLite3DB = DBMS
SQLite3DB is *sql.DB for executing SQL with SQLite3.
func NewSQLite3DB ¶ added in v0.1.1
func NewSQLite3DB(config SQLite3Config) (SQLite3DB, func(), error)
NewSQLite3DB creates *sql.DB for SQLite3. The return function is the function to close the DB.