Documentation
¶
Overview ¶
Package interactive is komando's interactive mode: the screens that help a person build a command line (C162). It returns the line as argv; internal/cli runs it as if it was typed, so every check of a typed line still applies. It reads keys and draws, nothing more: no command runs here (TestInteractiveImports).
Index ¶
Constants ¶
const MaxRows = 30
MaxRows is how many rows a list shows at once, as the line prompts do (promptMaxRows); typing narrows it.
Variables ¶
This section is empty.
Functions ¶
func Draw ¶
Draw is the list as lines, top to bottom, in an order that never changes: the question with what was typed, the help when asked for, the rows of the page, a line under them when there is something to say, and the key line. It only reads l.
func DrawForm ¶
DrawForm is the form as lines: the command's words, then the field being filled (a list as Draw shows it, or the question with what is typed), then its key line. It only reads f.
func DrawReview ¶
DrawReview is the review as lines: the question, the whole line with a $ first, then its keys. A line wider than the window wraps; no part of it is cut, so what runs is what was shown.
Types ¶
type Field ¶
type Field struct {
Key string // the answer's key: arg0, arg1 ... or flag:NAME
Ask string // the question
Help string
Required bool
Free bool // with Rows: other text may be typed (tag:prod)
Advanced bool // asked only after "more options"
Default func(Answers) string // what an empty Enter takes; nil: nothing
Rows func(Answers) []Row // the list it is picked from; nil: typed
Show func(Answers) bool // asked only while true; nil: always
// Check is why an answer is refused; "" takes it.
Check func(a Answers, v string) string
// Clean takes a password out of a pasted address (user:password@);
// found says one was there. The screen never draws it.
Clean func(v string) (clean string, found bool)
}
Field is one question of a form, as internal/cli describes it from the command and its form hint. A secret or a value komando makes is never a field: internal/cli leaves those out. The functions read the answers given so far and nothing else may change through them.
type Form ¶
type Form struct {
Title string
// contains filtered or unexported fields
}
Form asks a command's fields one after another: the required ones first, then the other main ones; the advanced ones only when the person asks for more options. Its answers go back to internal/cli, which builds the line.
type List ¶
type List struct {
Question string
Help string
Rows []Row
Free bool
// contains filtered or unexported fields
}
List is a list with type-to-search. Free: when no row matches, Enter takes the typed text as it is (a selector such as @web or tag:prod).
type Menu ¶
type Menu struct {
// contains filtered or unexported fields
}
Menu is the first screen: the command tree of the capability table as nested lists, one level per word a person types. Enter on a word opens the words after it; Enter on a whole command takes it.
func NewMenu ¶
func NewMenu(leaves []capability.Leaf) *Menu
NewMenu is the tree of the built leaves, at its top level.
type Review ¶
type Review struct {
// contains filtered or unexported fields
}
Review is the last screen: the line built from the answers, as internal/cli prints it (quoted, secrets masked), before it runs.