Documentation
¶
Index ¶
- type Context
- func (c *Context) AskBool(question string, defaultAnswer string) bool
- func (c *Context) AskChoice(question string, choices []string, defaultAnswer string) string
- func (c *Context) AskInt(question string, min int64, max int64, defaultAnswer string) int64
- func (c *Context) AskPassword(question string, reader func(int) ([]byte, error)) string
- func (c *Context) AskString(question string, defaultAnswer string, validate func(string) error) string
- func (c *Context) InputYAML(out interface{}) error
- func (c *Context) Output(format string, a ...interface{})
- type MemoryStreams
- func (s *MemoryStreams) Err() string
- func (s *MemoryStreams) InputAppend(text string)
- func (s *MemoryStreams) InputAppendBoolAnswer(answer bool)
- func (s *MemoryStreams) InputAppendLine(line string)
- func (s *MemoryStreams) InputRead() string
- func (s *MemoryStreams) InputReset(input string)
- func (s *MemoryStreams) Out() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context captures the environment the sub-command is being run in, such as in/out/err streams and command line arguments.
func NewContext ¶
NewContext creates a new command context with the given parameters.
func NewMemoryContext ¶
func NewMemoryContext(streams *MemoryStreams) *Context
NewMemoryContext creates a new command Context using the given in-memory streams.
func (*Context) AskPassword ¶
AskPassword asks the user to enter a password. The reader function used to read the password without echoing characters must be passed (usually terminal.ReadPassword from golang.org/x/crypto/ssh/terminal).
func (*Context) AskString ¶
func (c *Context) AskString(question string, defaultAnswer string, validate func(string) error) string
AskString asks the user to enter a string, which optionally conforms to a validation function.
type MemoryStreams ¶
type MemoryStreams struct {
// contains filtered or unexported fields
}
MemoryStreams provide an in-memory version of the system stdin/stdout/stderr streams.
func NewMemoryStreams ¶
func NewMemoryStreams(input string) *MemoryStreams
NewMemoryStreams creates a new set of in-memory streams with the given user input.
func (*MemoryStreams) Err ¶
func (s *MemoryStreams) Err() string
Err returns the current content of the err stream.
func (*MemoryStreams) InputAppend ¶
func (s *MemoryStreams) InputAppend(text string)
InputAppend adds the given text to the current input.
func (*MemoryStreams) InputAppendBoolAnswer ¶
func (s *MemoryStreams) InputAppendBoolAnswer(answer bool)
InputAppendBoolAnswer adds a new "yes" or "no" line depending on the answer.
func (*MemoryStreams) InputAppendLine ¶
func (s *MemoryStreams) InputAppendLine(line string)
InputAppendLine adds a single line to the input stream.
func (*MemoryStreams) InputRead ¶
func (s *MemoryStreams) InputRead() string
InputRead returns the current input string.
func (*MemoryStreams) InputReset ¶
func (s *MemoryStreams) InputReset(input string)
InputReset replaces the data in the input stream.
func (*MemoryStreams) Out ¶
func (s *MemoryStreams) Out() string
Out returns the current content of the out stream.