Documentation
¶
Overview ¶
Package app contains functionality related to creating an interactive command-line interface environment with all the necessary dependencies.
The goal of the app package is to provide a single, reusable base for building client-only MOTKI CLI applications.
This package imports every other motki/cli package. As such, it cannot be imported from the "library" portion of the project. It is intended to be used from external packages only. For a real example of this, check the motki command source code.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CLIConfig ¶
CLIConfig wraps an app.Config and contains optional credentials.
func NewCLIConfig ¶
NewCLIConfig creates a CLI-specific configuration using the given conf.
func (CLIConfig) WithCredentials ¶
WithCredentials returns a copy of the CLIConfig with the given credentials embedded.
type CLIEnv ¶
type CLIEnv struct {
*app.ClientEnv
CLI *cli.Server
Prompter *cli.Prompter
// contains filtered or unexported fields
}
A CLIEnv wraps a ClientEnv, providing CLI specific facilities.
func NewCLIEnv ¶
NewCLIEnv initializes a new CLI environment.
If the given CLIConfig contains a username or password, authentication will be attempted. If authentication fails, an error is returned.
func (*CLIEnv) BlockUntilSignal ¶
BlockUntilSignal will block until it receives the signals signal.
This function attempts to perform a graceful shutdown, shutting down all related services and doing whatever clean up processes are necessary.
func (*CLIEnv) LoopCLI ¶
func (env *CLIEnv) LoopCLI()
LoopCLI starts an endless loop to perform commands read from stdin.
This function is intended to be started in a goroutine. The loop will end when the application exits or when the associated Env receives an abort signal. Use this method in combination with env.BlockUntilSignal() for clean exits.
env, err := app.NewCLIEnv(conf, "") // handle err... go env.LoopCLI() env.BlockUntilSignal()