Documentation ¶
Overview ¶
Package input contains identifiers used in getting TunaQuest command input from CLI or other sources of input.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DirectCommandReader ¶
type DirectCommandReader struct {
// contains filtered or unexported fields
}
DirectCommandReader implements command.Reader and reads commands from any generic input stream directly. It can be used generically with any io.Reader but does not sanitize the input of control and escape sequences.
DirectCommandReader should not be used directly; instead, create one with NewDirectReader.
func NewDirectReader ¶
func NewDirectReader(r io.Reader) *DirectCommandReader
Create a new DirectCommandReader and initialize a buffered reader on the provided reader. The returned CommandReader must have Close() called on it before disposal to properly teardown readline resources.
func (*DirectCommandReader) AllowBlank ¶
func (dcr *DirectCommandReader) AllowBlank(allow bool)
AllowBlank sets whether blank output is allowed. By default it is not.
func (*DirectCommandReader) Close ¶
func (dcr *DirectCommandReader) Close() error
Close cleans up resources associated with the DirectCommandReader.
func (*DirectCommandReader) ReadCommand ¶
func (dcr *DirectCommandReader) ReadCommand() (string, error)
ReadCommand reads the next line from stdin. The returned string will only be empty if there is an error reading input, otherwise this function is blocked on until a line containing non-space characters is read.
If at end of input, the returned string will be empty and error will be io.EOF. If any other error occurs, the returned string will be empty and error will be that error.
type InteractiveCommandReader ¶
type InteractiveCommandReader struct {
// contains filtered or unexported fields
}
InteractiveCommandReader implements command.Reader and reads commands from stdin using a go implementation of the GNU Readline library. This keeps input clear of all typing and editing escape sequences and enables the use of command history. This should in general probably only be used when directly connecting to a TTY for input.
InteractiveCommandReader should not be used directly; instead, create one with NewInteractiveReader.
func NewInteractiveReader ¶
func NewInteractiveReader() (*InteractiveCommandReader, error)
Create a new InteractiveCommandReader and initialize readline. The returned InteractiveCommandReader must have Close() called on it before disposal to properly teardown readline resources.
func (*InteractiveCommandReader) AllowBlank ¶
func (icr *InteractiveCommandReader) AllowBlank(allow bool)
AllowBlank sets whether blank output is allowed. By default it is not.
func (*InteractiveCommandReader) Close ¶
func (icr *InteractiveCommandReader) Close() error
Close cleans up readline resources and other resources associated with the InteractiveCommandReader.
func (*InteractiveCommandReader) GetPrompt ¶
func (icr *InteractiveCommandReader) GetPrompt() string
GetPrompt gets the current prompt.
func (*InteractiveCommandReader) ReadCommand ¶
func (icr *InteractiveCommandReader) ReadCommand() (string, error)
ReadCommand reads the next command from stdin. The returned string will only be empty if there is an error, otherwise this function is blocked on until a line consisting of more than empty or whitespace-only input is read.
If at end of input, the returned string will be empty and error will be io.EOF. If any other error occurs, the returned string will be empty and error will be that error.
func (*InteractiveCommandReader) SetPrompt ¶
func (icr *InteractiveCommandReader) SetPrompt(p string)
SetPrompt updates the prompt to the given text.