config

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package config manage sqly configuration

Package config manage sqly configuration

Index

Constants

This section is empty.

Variables

View Source
var (
	// Version is sqly command version. Version value is assigned by LDFLAGS.
	Version string
	// Stdout is new instance of Writer which handles escape sequence for stdout.
	Stdout = colorable.NewColorableStdout()
	// Stderr is new instance of Writer which handles escape sequence for stderr.
	Stderr = colorable.NewColorableStderr()
)
View Source
var (
	// ErrEmptyArg is argument for NewArg() is empty
	ErrEmptyArg = errors.New("argument is empty")
)

Functions

func GetVersion added in v0.0.6

func GetVersion() string

GetVersion return sqly command version. Version global variable is set by ldflags.

func InitSQLite3 added in v0.8.0

func InitSQLite3()

InitSQLite3 registers the sqlite3 driver.

Types

type Arg

type Arg struct {
	// FilePath is CSV file paths that are imported into the DB.
	FilePaths []string
	// Output is configuration for output data to file.
	Output *Output
	// HelpFlag is flag whether print usage or not (for --help option)
	HelpFlag bool
	// VersionFlag is flag whether print version or not (for --version option)
	VersionFlag bool
	// Query is SQL query (for --sql option)
	Query string
	// Usage message
	Usage string
	// SheetName is excel sheet name that is imported into the DB.
	SheetName string
	// Version print version message
	Version func()
}

Arg is a structure for managing options and arguments

func NewArg

func NewArg(args []string) (*Arg, error)

NewArg return *Arg that is assigned the result of parsing os.Args. NOTE: Adding options directly to the pflag package results in a double option definition error when NewArg() is called multiple times. Therefore, create a new FlagSet() and add it to pflags. Ref. https://stackoverflow.com/questions/61216174/how-to-test-cli-flags-currently-failing-with-flag-redefined

func (*Arg) NeedsOutputToFile added in v0.0.10

func (a *Arg) NeedsOutputToFile() bool

NeedsOutputToFile whether the data needs to be output to the file

type Config added in v0.0.5

type Config struct {
	HistoryDBPath string `env:"SQLY_HISTORY_DB_PATH"`
}

Config is sqly configuration.

func NewConfig added in v0.0.5

func NewConfig() (*Config, error)

NewConfig return *Config.

func (*Config) CreateDir added in v0.0.5

func (c *Config) CreateDir() error

CreateDir make configuration directory.

func (*Config) Dir added in v0.0.5

func (c *Config) Dir() string

Dir return configuration directory path.

type HistoryDB added in v0.0.5

type HistoryDB *sql.DB

HistoryDB is *sql.DB for sqly shell history.

func NewHistoryDB added in v0.0.5

func NewHistoryDB(c *Config) (HistoryDB, func(), error)

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

type MemoryDB added in v0.0.5

type MemoryDB *sql.DB

MemoryDB is *sql.DB for excuting sql.

func NewInMemDB added in v0.0.5

func NewInMemDB() (MemoryDB, func(), error)

NewInMemDB create *sql.DB for SQLite3. SQLite3 store data in memory. The return function is the function to close the DB.

type Output added in v0.0.10

type Output struct {
	// FilePath is output destination path
	FilePath string
	// Mode is enum to specify output method
	Mode model.PrintMode
}

Output is configuration for output data to file.

Jump to

Keyboard shortcuts

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