Documentation ¶
Index ¶
- func AddGlobalConfigFiles(cfg *mybase.Config)
- func AddGlobalOptions(cmd *mybase.Command)
- func CloseCachedConnectionPools()
- func NewInstance(driver, dsn string) (*tengo.Instance, error)
- func ProcessSpecialGlobalOptions(cfg *mybase.Config) error
- func PromptPassword() (string, error)
- func RealConnectOptions(connectOpts string) (string, error)
- func SplitConnectOptions(connectOpts string) (map[string]string, error)
- type ShellOut
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 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 ProcessSpecialGlobalOptions ¶
ProcessSpecialGlobalOptions performs special handling of global options with unusual semantics -- handling restricted placement of host and schema; obtaining a password from MYSQL_PWD or STDIN; enable debug logging.
func PromptPassword ¶
PromptPassword reads a password from STDIN without echoing the typed characters. Requires that STDIN is a TTY.
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.
Types ¶
type ShellOut ¶
type ShellOut struct { Command string PrintableCommand string // Used in String() if non-empty; useful for hiding passwords in output Dir string // Initial working dir for the command if non-empty Timeout time.Duration // If > 0, kill process after this amount of time CombineOutput bool // If true, combine stdout and stderr into a single stream // contains filtered or unexported fields }
ShellOut represents a command-line for an external command, executed via sh -c
func NewInterpolatedShellOut ¶
NewInterpolatedShellOut takes a shell command-line containing variables of format {VARNAME}, and performs substitution on them based on the supplied map of variable names to values.
Variable names should be supplied in all-caps in the variables map. Inside of command, they are case-insensitive. If any unknown variable is contained in the command string, a non-nil error will be returned and the unknown variable will not be interpolated.
As a special case, any variable name may appear with an X suffix. This will still be replaced as normal in the generated ShellOut.Command, but will appear as all X's in ShellOut.PrintableCommand. For example, if the command string contains "{PASSWORDX}" and variables has a key "PASSWORD", it will be replaced in a manner that obfuscates the actual password in PrintableCommand.
func (*ShellOut) Run ¶
Run shells out to the external command and blocks until it completes. It returns an error if one occurred. STDIN, STDOUT, and STDERR will be redirected to those of the parent process.
func (*ShellOut) RunCapture ¶
RunCapture shells out to the external command and blocks until it completes. It returns the command's STDOUT output as a single string, optionally with STDERR if CombineOutput is true; otherwise STDERR is redirected to that of the parent process. STDIN is always redirected from the parent process.
func (*ShellOut) RunCaptureSplit ¶
RunCaptureSplit behaves like RunCapture, except the output will be tokenized. If newlines are present in the output, it will be split on newlines; else if commas are present, it will be split on commas; else ditto for tabs; else ditto for spaces. Blank tokens will be ignored (i.e. 2 delimiters in a row get treated as a single delimiter; leading or trailing delimiter is ignored). Does NOT provide any special treatment for quoted fields in the output.