Documentation
¶
Overview ¶
Package cmdtree describes the command tree as data. The same description backs `search`, the command surface snapshot and the description lint, so generated and hand-written commands are treated alike.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitDefaults ¶
InitDefaults adds what cobra otherwise adds only when a command runs: the help and completion commands and the --help and --version flags of the root. Call it before Walk, so that a tree built in a test and the tree of a running command are walked alike.
func Lint ¶
Lint checks the descriptions that `search`, `--help` and the agent docs are built from. A command whose summary only repeats its name ("dns", "Operations for records", "Manage accounts") cannot be found by describing a task.
cobra's completion commands and the flags cobra adds are skipped: cobra writes their text, which changes with cobra and is not ours to fix.
Types ¶
type Command ¶
type Command struct {
Path string `json:"path"`
Usage string `json:"usage"`
Short string `json:"short"`
// Long is searched but left out of the surface snapshot: it is prose and
// may embed machine-specific values such as the config path.
Long string `json:"-"`
Aliases []string `json:"aliases,omitempty"`
// Runnable is false for groups that only hold subcommands, and for topics.
Runnable bool `json:"runnable"`
// Topic marks a help topic: text read with `<app> help <topic>`.
Topic bool `json:"topic,omitempty"`
Flags []Flag `json:"flags,omitempty"`
// contains filtered or unexported fields
}
Command is one visible command.
type Flag ¶
type Flag struct {
Name string `json:"name"`
Shorthand string `json:"shorthand,omitempty"`
Type string `json:"type"`
Default string `json:"default,omitempty"`
Usage string `json:"usage"`
// contains filtered or unexported fields
}
Flag is a local flag of a command. Global flags are listed on the root only.