Documentation
¶
Index ¶
- Constants
- Variables
- func CheckArgc(args []string, valid []int) error
- func IntArg(arg string, limits [2]int, base int) (int, error)
- func TableString(rows [][]string, csize []int, cmargin int) string
- func UintArg(arg string, limits [2]uint, base int) (uint, error)
- type CLI
- func (c *CLI) DisplayHistory(args []string) string
- func (c *CLI) Exit()
- func (c *CLI) GeneralHelp()
- func (c *CLI) HistoryLoad(path string)
- func (c *CLI) HistorySave(path string)
- func (c *CLI) Loop(fn func() bool, exitKey rune) bool
- func (c *CLI) Put(s string)
- func (c *CLI) Run()
- func (c *CLI) Running() bool
- func (c *CLI) SetLine(line string)
- func (c *CLI) SetPrompt(prompt string)
- func (c *CLI) SetRoot(root []MenuItem)
- type Help
- type Hint
- type Leaf
- type Linenoise
- func (l *Linenoise) HistoryAdd(line string)
- func (l *Linenoise) HistoryLoad(fname string)
- func (l *Linenoise) HistorySave(fname string)
- func (l *Linenoise) HistorySetMaxlen(n int)
- func (l *Linenoise) Loop(fn func() bool, exitKey rune) bool
- func (l *Linenoise) PrintKeycodes()
- func (l *Linenoise) Read(prompt, init string) (string, error)
- func (l *Linenoise) SetCompletionCallback(fn func(string) []string)
- func (l *Linenoise) SetHintsCallback(fn func(string) *Hint)
- func (l *Linenoise) SetHotkey(key rune)
- func (l *Linenoise) SetMultiline(mode bool)
- type Menu
- type MenuItem
- type USER
Constants ¶
const ( KeycodeNull = 0 KeycodeCtrlA = 1 KeycodeCtrlB = 2 KeycodeCtrlC = 3 KeycodeCtrlD = 4 KeycodeCtrlE = 5 KeycodeCtrlF = 6 KeycodeCtrlH = 8 KeycodeTAB = 9 KeycodeLF = 10 KeycodeCtrlK = 11 KeycodeCtrlL = 12 KeycodeCR = 13 KeycodeCtrlN = 14 KeycodeCtrlP = 16 KeycodeCtrlT = 20 KeycodeCtrlU = 21 KeycodeCtrlW = 23 KeycodeESC = 27 KeycodeBS = 127 )
Keycodes
Variables ¶
var ErrQuit = errors.New("quit")
ErrQuit is returned when the user has quit line editing.
var HistoryHelp = []Help{
{"<cr>", "display all history"},
{"<index>", "recall history entry <index>"},
}
HistoryHelp is help for the history command.
Functions ¶
func TableString ¶
TableString returns a string for a table of row by column strings. Each column string will be left justified and aligned.
Types ¶
type CLI ¶
type CLI struct { User USER // user provided object // contains filtered or unexported fields }
CLI stores the CLI state.
func (*CLI) DisplayHistory ¶
DisplayHistory displays the command history.
func (*CLI) HistoryLoad ¶
HistoryLoad loads command history from a file.
func (*CLI) HistorySave ¶
HistorySave saves command history to a file.
type Linenoise ¶
type Linenoise struct {
// contains filtered or unexported fields
}
Linenoise stores line editor state.
func (*Linenoise) HistoryAdd ¶
HistoryAdd adds a new entry to the history.
func (*Linenoise) HistoryLoad ¶
HistoryLoad loads history from a file.
func (*Linenoise) HistorySave ¶
HistorySave saves the history to a file.
func (*Linenoise) HistorySetMaxlen ¶
HistorySetMaxlen sets the maximum length for the history. Truncate the current history if needed.
func (*Linenoise) Loop ¶
Loop calls the provided function in a loop. Exit when the function returns true or when the exit key is pressed. Returns true when the loop function completes, false for early exit.
func (*Linenoise) PrintKeycodes ¶
func (l *Linenoise) PrintKeycodes()
PrintKeycodes prints scan codes on the screen for debugging/development purposes.
func (*Linenoise) SetCompletionCallback ¶
SetCompletionCallback sets the completion callback function.
func (*Linenoise) SetHintsCallback ¶
SetHintsCallback sets the hints callback function.
func (*Linenoise) SetHotkey ¶
SetHotkey sets the hotkey that causes line editing to exit. The hotkey will be appended to the line buffer but not displayed.
func (*Linenoise) SetMultiline ¶
SetMultiline sets multiline editing mode.