Documentation
¶
Overview ¶
Package cli implements datavase's command-line surface.
App takes its dependencies as fields so every command can be exercised in tests without a terminal, a keychain or a database.
Index ¶
Constants ¶
const CheckTimeout = 15 * time.Second
CheckTimeout bounds how long `dv check` waits before giving up.
Variables ¶
This section is empty.
Functions ¶
func HandleVersion ¶
HandleVersion answers a request for the version, reporting whether it did.
It is a free function rather than a command on App because it has to run before the configuration is read: someone checking which build they have should not first be told to write a config file. That also means the flag spellings never reach flag.Parse, which would reject them as undefined.
Types ¶
type App ¶
type App struct {
Config *config.Config
Secrets secret.Store
Out io.Writer
Err io.Writer
// ReadPassword prompts for a password without echoing it. It is a field
// so tests can supply input without a terminal.
ReadPassword func(prompt string) (string, error)
// Probe opens a connection and returns the server version. It is a field
// so the command can be tested without a database.
Probe func(ctx context.Context, ds *config.DataSource, password string) (string, error)
// OpenUI connects and runs the terminal interface. It is a field so the
// dispatch logic can be tested without starting a terminal.
OpenUI func(ctx context.Context, ds *config.DataSource, password string, cfg *config.Config, opt UIOptions) error
}
App holds everything the commands need.
type UIOptions ¶ added in v0.3.0
type UIOptions struct {
// WorkDir is the directory of SQL work to attach, from --dir. Empty means
// the session starts unattached.
WorkDir string
}
UIOptions are the choices that belong to one invocation rather than to the configuration file.
It is a struct rather than more parameters so that the next such choice does not change the signature every caller and every test has to spell out.