config

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package config provides functionality to read environment variables, runtime arguments, and configuration files.

Index

Constants

This section is empty.

Variables

Set is config providers.

View Source
var (
	// Version is sqluv command version. Version value is assigned by LDFLAGS.
	Version string
)

Functions

func DecryptPassword added in v0.1.0

func DecryptPassword(encryptedPassword string) (string, error)

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

func EncryptPassword(password string) (string, error)

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

func IsEncrypted(password string) bool

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

func NewArgument(args []string) (*Argument, error)

NewArgument creates a new Argument instance.

func (*Argument) CanUsage

func (a *Argument) CanUsage() bool

CanUsage returns true if sqluv command can show usage message.

func (*Argument) CanVersion

func (a *Argument) CanVersion() bool

CanVersion returns true if sqluv command can show version message.

func (*Argument) Files

func (a *Argument) Files() []*model.File

Files returns CSV/TSV/LTSV file path list.

func (*Argument) Usage

func (a *Argument) Usage() string

Usage returns sqluv command usage.

func (*Argument) Version

func (a *Argument) Version() string

Version returns sqluv command version.

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

func NewDBConfig() (*DBConfig, error)

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

func (cm *DBConfig) RemoveConnection(name string) error

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 DBMS added in v0.1.0

type DBMS *sql.DB

DBMS is a common interface for database connections

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

type HistoryDB *sql.DB

HistoryDB is *sql.DB for sqly shell history.

func NewHistoryDB added in v0.1.3

func NewHistoryDB(cfg *DBConfig) (HistoryDB, func(), error)

NewHistoryDB create *sql.DB for history. The return function is the function to close the DB.

type MemoryDB

type MemoryDB *sql.DB

MemoryDB is *sql.DB for excuting sql.

func NewMemoryDB

func NewMemoryDB() (MemoryDB, func(), error)

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.

Jump to

Keyboard shortcuts

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