Documentation ¶
Index ¶
- func AddGlobalConfigFiles(cfg *mybase.Config)
- func AddGlobalOptions(cmd *mybase.Command)
- func CloseCachedConnectionPools()
- func FlushInstanceCache()
- func IgnorePatterns(cfg *mybase.Config) ([]tengo.ObjectPattern, error)
- func InteractivePasswordInput() (string, error)
- func NewInstance(driver, dsn string) (*tengo.Instance, error)
- func NoInteractiveInput() (string, error)
- func ProcessSpecialGlobalOptions(cfg *mybase.Config) error
- func PromptPassword(promptArgs ...interface{}) (string, error)
- func RealConnectOptions(connectOpts string) (string, error)
- func SplitConnectOptions(connectOpts string) (map[string]string, error)
- func StderrIsTerminal() bool
- func StdinIsTerminal() bool
- func StdoutIsTerminal() bool
- func TerminalWidth(fd int) (int, error)
- func WrapStringWithPadding(s string, lim int, padder string) string
- type PasswordInputSource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddGlobalConfigFiles ¶
AddGlobalConfigFiles takes the mybase.Config generated from the CLI and adds global option files as sources.
func AddGlobalOptions ¶
AddGlobalOptions adds Skeema global options to the supplied mybase.Command. Typically cmd should be the top-level Command / Command Suite.
func CloseCachedConnectionPools ¶
func CloseCachedConnectionPools()
CloseCachedConnectionPools closes all connection pools in all cached Instances that were created via NewInstance.
func FlushInstanceCache ¶
func FlushInstanceCache()
FlushInstanceCache closes all connection pools in all cached Instances that were created via NewInstance, and then flushes the cache entirely.
func IgnorePatterns ¶ added in v1.9.0
func IgnorePatterns(cfg *mybase.Config) ([]tengo.ObjectPattern, error)
IgnorePatterns compiles the regexes in the supplied mybase.Config's ignore-* options. If all supplied regex strings were valid, a slice of tengo.ObjectPattern is returned; otherwise, an error with the first invalid regex is returned.
func InteractivePasswordInput ¶ added in v1.9.0
InteractivePasswordInput reads a password from STDIN. This only works if STDIN is a terminal.
func NewInstance ¶
NewInstance wraps tengo.NewInstance such that two identical requests will return the same *tengo.Instance. This helps reduce excessive creation of redundant connections.
func NoInteractiveInput ¶ added in v1.9.0
NoInteractiveInput always returns an error instead of attempting to read a password.
func ProcessSpecialGlobalOptions ¶
ProcessSpecialGlobalOptions performs special handling of global options with unusual semantics -- handling restricted placement of host and schema; obtaining a password from STDIN if requested; enable debug logging.
func PromptPassword ¶
PromptPassword reads a password from STDIN without echoing the typed characters. Requires that STDIN is a TTY. Optionally supply args to build a custom prompt string; first arg must be a string if so, with args behaving like those to fmt.Printf(). The prompt will be written to STDERR, unless STDERR is a non-terminal and STDOUT is a terminal, in which case STDOUT is used.
func RealConnectOptions ¶
RealConnectOptions takes a comma-separated string of connection options, strips any Go driver-specific ones, and then returns the new string which is now suitable for passing to an external tool.
func SplitConnectOptions ¶
SplitConnectOptions takes a string containing a comma-separated list of connection options (typically obtained from the "connect-options" option) and splits them into a map of individual key: value strings. This function understands single-quoted values may contain commas, and will properly treat them not as delimiters. Single-quoted values may also include escaped single quotes, and values in general may contain escaped commas; these are all also treated properly.
func StderrIsTerminal ¶ added in v1.10.0
func StderrIsTerminal() bool
StderrIsTerminal returns true if os.Stderr is a terminal.
func StdinIsTerminal ¶ added in v1.10.0
func StdinIsTerminal() bool
StdinIsTerminal returns true if os.Stdin is a terminal.
func StdoutIsTerminal ¶ added in v1.10.0
func StdoutIsTerminal() bool
StdoutIsTerminal returns true if os.Stdout is a terminal.
func TerminalWidth ¶ added in v1.5.3
TerminalWidth returns the width of the supplied file descriptor if it is a terminal. Otherwise, 0 and an error are returned.
func WrapStringWithPadding ¶ added in v1.5.3
WrapStringWithPadding performs word-wrapping at the given width limit, prepending the supplied padder string to each line after the first. The padder string's width is accounted for in the word-wrapping, on all lines (including the first, even though padding is not applied here to it.) To also pad the first line, prepend the padding to the *return value* of this function; this permits using a different header/padding on the first line if desired. If lim isn't larger than the length of padder, s is returned unchanged. Passing a zero or negative lim safely makes this function a no-op.
Types ¶
type PasswordInputSource ¶ added in v1.9.0
PasswordInputSource is a function that can be used to obtain a password interactively.
var PasswordPromptInput PasswordInputSource
PasswordPromptInput is the input source used by PromptPassword to obtain a password interactively, or to mock such an input for testing purposes.
func NewMockPasswordInput ¶ added in v1.9.0
func NewMockPasswordInput(mockPassword string) PasswordInputSource
NewMockPasswordInput returns a PasswordInputSource function which always returns the specified string.