Documentation
¶
Overview ¶
Package cli is a command-line interface and supporting libraries for interacting with a remote MOTKI application server.
This project contains the motki command source code, as well text-processing functionality.
Index ¶
- type Authenticator
- type Command
- type Prompter
- func (p *Prompter) Prompt(prompt string) (string, error)
- func (p *Prompter) PromptDecimal(prompt string, defVal *decimal.Decimal, ...) (decimal.Decimal, bool)
- func (p *Prompter) PromptInt(prompt string, defVal *int, filters ...func(int) (int, bool)) (int, bool)
- func (p *Prompter) PromptItemTypeDetail(prompt string, initialInput string) (*evedb.ItemTypeDetail, bool)
- func (p *Prompter) PromptRegion(prompt string, initialInput string) (*evedb.Region, bool)
- func (p *Prompter) PromptString(prompt string, defVal *string, filters ...func(string) (string, bool)) (string, bool)
- func (p *Prompter) PromptStringWithArgs(prompt string, defVal *string, filters ...func(string) (string, bool)) (string, []string, bool)
- func (p *Prompter) PromptWithSuggestion(prompt string, text string, pos int) (string, error)
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Authenticator ¶
type Authenticator interface {
Authenticated() bool
}
Authenticator is implemented by a type that is responsible for authentication.
type Command ¶
type Command interface { // Description returns a ~40 character sentence describing the command. Description() string // Prefixes defines the names that the command will be invoked under. // // This is a slice to allow for alternatives and shorthands to be considered // as a prefix for the command. Prefixes() []string // Handle executes the given subcmd, if any, with the given arguments. Handle(subcmd string, args ...string) // PrintHelp prints a helpful overview describing the Command its subcommands. PrintHelp() }
A Command is a single command that a Server supports.
Commands display description and help information. Each Command may support any number of sub-commands, all of which receive further arguments in a byte slice.
Commands are registered with a Server before beginning the Server's loop.
type Prompter ¶
type Prompter struct {
// contains filtered or unexported fields
}
A Prompter handles prompting the user for well-defined input.
func (*Prompter) PromptDecimal ¶
func (p *Prompter) PromptDecimal(prompt string, defVal *decimal.Decimal, filters ...func(decimal.Decimal) (decimal.Decimal, bool)) (decimal.Decimal, bool)
PromptDecimal prompts the user for a valid decimal input.
If defVal is not nil, the prompt will be pre-populated with the default value.
Additionally, any number of filter funcs can be passed in to perform custom validation and filtering on the user's input. Filter functions receive the value received from the prompt and return the new value and and indicator whether the value is valid.
func (*Prompter) PromptInt ¶
func (p *Prompter) PromptInt(prompt string, defVal *int, filters ...func(int) (int, bool)) (int, bool)
PromptInt prompts the user for a valid integer input.
If defVal is not nil, the prompt will be pre-populated with the default value.
Additionally, any number of filter functions can be passed in to perform custom validation and filtering on the user's input. Filter functions receive the value received from the prompt and return the new value and and indicator whether the value is valid.
func (*Prompter) PromptItemTypeDetail ¶
func (p *Prompter) PromptItemTypeDetail(prompt string, initialInput string) (*evedb.ItemTypeDetail, bool)
PromptItemTypeDetail prompts the user for a valid item type input.
If the user enters an integer, it is treated as the item's Type ID. Otherwise, the value is used to lookup item types.
This function also accepts an initial input that should be used to as the first round of prompt input.
func (*Prompter) PromptRegion ¶
PromptRegion prompts the user for a valid region input.
If the user enters an integer, it is treated as the region's Region ID. Otherwise, the value is used to lookup regions.
This function also accepts an initial input that should be used to as the first round of prompt input.
func (*Prompter) PromptString ¶
func (p *Prompter) PromptString(prompt string, defVal *string, filters ...func(string) (string, bool)) (string, bool)
PromptString prompts the user for any string input.
If defVal is not nil, the prompt will be pre-populated with the default value.
Additionally, any number of filter funcs can be passed in to perform custom validation and filtering on the user's input. Filter functions receive the value received from the prompt and return the new value and and indicator whether the value is valid.
func (*Prompter) PromptStringWithArgs ¶
func (p *Prompter) PromptStringWithArgs(prompt string, defVal *string, filters ...func(string) (string, bool)) (string, []string, bool)
PromptStringWithArgs prompts the user for any string input.
This function differs from PromptString in that it will split the received input by spaces, returning the first value as the main value, and a slice of additional arguments.
If defVal is not nil, the prompt will be pre-populated with the default value.
Additionally, any number of filter funcs can be passed in to perform custom validation and filtering on the user's input. Filter functions receive the value received from the prompt and return the new value and and indicator whether the value is valid.
type Server ¶
A Server handles command-line requests and prints responses to standard output.
func NewServer ¶
func NewServer(logger log.Logger, a Authenticator) *Server
NewServer initializes a new CLI server.
func (*Server) LoopCLI ¶
func (srv *Server) LoopCLI()
LoopCLI starts an endless loop to perform commands read from stdin.
func (*Server) PrintHelp ¶
func (srv *Server) PrintHelp()
PrintHelp prints the application-level help text.
func (*Server) SetCommands ¶
Directories
¶
Path | Synopsis |
---|---|
Package app contains functionality related to creating an interactive command-line interface environment with all the necessary dependencies.
|
Package app contains functionality related to creating an interactive command-line interface environment with all the necessary dependencies. |
cmd
|
|
motki
Command motki is a utility for interacting with a remote MOTKI application server.
|
Command motki is a utility for interacting with a remote MOTKI application server. |
Package command contains the implementations for subcommands supported by the motki command.
|
Package command contains the implementations for subcommands supported by the motki command. |
Package editor is an interactive command-line editor that supports sub-commands with arguments.
|
Package editor is an interactive command-line editor that supports sub-commands with arguments. |
Package text contains functions for formatting console text.
|
Package text contains functions for formatting console text. |
banner
Package banner is a dynamic ASCII art banner generator.
|
Package banner is a dynamic ASCII art banner generator. |