Documentation
¶
Overview ¶
Package run holds the run.Run construct, which encapsulates CLI state for a command execution.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewContext ¶
NewContext returns ctx with ru added as a value.
func NewQueryContext ¶
func NewQueryContext(ru *Run, args map[string]string) *libsq.QueryContext
NewQueryContext returns a *libsq.QueryContext constructed from ru.
Types ¶
type Run ¶
type Run struct {
// Stdin typically is os.Stdin, but can be changed for testing.
Stdin *os.File
// Out is the output destination, typically os.Stdout.
Out io.Writer
// ErrOut is the error output destination, typically os.Stderr.
ErrOut io.Writer
// Cmd is the command instance provided by cobra for
// the currently executing command. This field will
// be set before the command's runFunc is invoked.
Cmd *cobra.Command
// Args is the arg slice supplied by cobra for
// the currently executing command. This field will
// be set before the command's runFunc is invoked.
Args []string
// Config is the run's config.
Config *config.Config
// ConfigStore manages config persistence.
ConfigStore config.Store
// OptionsRegistry is a registry of CLI options.Opt instances.
OptionsRegistry *options.Registry
// DriverRegistry is a registry of driver implementations.
DriverRegistry *driver.Registry
// Files manages file access.
Files *source.Files
// Pools mediates access to db pools.
Pools *driver.Pools
// Writers holds the various writer types that
// the CLI uses to print output.
Writers *output.Writers
// Cleanup holds cleanup functions.
Cleanup *cleanup.Cleanup
}
Run is a container for injectable resources passed to all cobra exec funcs. The Close method should be invoked when the Run is no longer needed.
func FromContext ¶
FromContext extracts the Run added to ctx via NewContext.
Click to show internal directories.
Click to hide internal directories.