Documentation
¶
Overview ¶
Package command holds what the generated behavior commands share: flags derived from an input type's tags, and the one table layout every behavior's output renders in, driven by its output type's tags. The commands themselves are generated into internal/behaviors/<name>/gen/cli.go.
Index ¶
- Constants
- func Annotations(b *behavior.Behavior, m *behavior.Method) map[string]string
- func Args(input any) []string
- func Columns(out reflect.Type) []clicommand.Column
- func ExampleFlags(input any) string
- func GroupAnnotations(b *behavior.Behavior) map[string]string
- func Output(b *behavior.Behavior, m *behavior.Method) string
- func Print(b *behavior.Behavior, method string, out any, traceID string)
- func ReferenceFolder(b *behavior.Behavior) string
- func ReferencePage(b *behavior.Behavior) string
- func ReferenceUp(b *behavior.Behavior) string
- func Screen(args []string) string
- func SettingFlags(fs *pflag.FlagSet, v *viper.Viper)
- func Stdin(input any) string
- func Table(m *behavior.Method, r Result) cli.Section
- type Flag
- type Result
Constants ¶
const InternalFolder = "internal"
InternalFolder is the folder of the reference pages of the internal behaviors, which have no area, after the folders of the areas.
const InternalLabel = "Internal"
InternalLabel is the label of InternalFolder in the sidebar and the navbar.
Variables ¶
This section is empty.
Functions ¶
func Annotations ¶
Annotations are the docs annotations of a method's command: the permission that it needs, and its result, which is what each example does on the host and the calls that it refuses.
func Args ¶
Args are the flags that set input's non-zero fields, as a command line takes them. A secret is its reference, or - for a literal value, which the command reads from standard input: Stdin is what it reads.
func Columns ¶
func Columns( out reflect.Type, ) []clicommand.Column
Columns are the output fields that a behavior's result table shows, in field order: the command layer's columns of the output type, except changed, which the table renders as the row's status.
func ExampleFlags ¶
ExampleFlags is the flags of an example's command line: --target and the flags of input, as the help and the pages write them.
func GroupAnnotations ¶
GroupAnnotations are the docs annotations of a behavior's own command: a note that links to the page of the behavior.
func Output ¶
Output is what each example of m prints, as the CLI prints it, colors included: the command and its table for one host, the same command for the fleet, where one host skips, and the API's response with --json. Each screen is a fenced ansi block, which the docs site shows as a terminal. An example whose output is not an object, or a list of them, has none.
func Print ¶
Print writes the answer of method of b, out, the method's response type: the job ID, the trace ID of the call, and the table every behavior renders. The command runtime calls it through printResults.
func ReferenceFolder ¶
ReferenceFolder is the folder of b's reference page under reference/behaviors: the folder of its area, such as hardware, or InternalFolder for an internal behavior, which has no area.
func ReferencePage ¶
ReferencePage is b's reference page from reference/behaviors, such as hardware/disk/disk.md: each behavior's page is in a folder of its own, in the folder of its area. A behavior that Of nests has its folder in the folder of its parent, as its command is under the parent's, such as security/user/sshkey/sshkey.md.
func ReferenceUp ¶
ReferenceUp is the path from the folder of b's reference page up to reference/behaviors, such as ../../ for hardware/disk/disk.md.
func Screen ¶
Screen is the screen of the first example of a behavior's method, as the CLI prints it, for a page that a person wrote: the osapi:output marker gives its arguments. They are the behavior, the method, then each host, as host, host:skipped or host:failed. One host is --target host; more are --target _all, and each answers in the order given. With --json last, it is the API's response, which the CLI prints with no table and no color.
func SettingFlags ¶
SettingFlags adds a flag to fs for every behavior setting, named by Key.Flag, such as --sysctl-dir, and binds it to the setting's key in v the way agent.go binds its own flags. Behaviors register in package init, before this runs, so every setting is here; v resolves the flag, then the environment, then the file, then the default when the config is read.
func Stdin ¶
Stdin is what the command line of Args reads from standard input: the literal value of input's secret field, or "" when it has none. A command reads one value from standard input, so a second literal is not read.
func Table ¶
Table renders a result the one way every behavior command prints: one row per result, the output fields as columns, and changed folded into the row's status for a write. A host that failed or was skipped is listed under the table with its reason. Each value prints as the command layer prints it, by its field's tags.
Types ¶
type Flag ¶
type Flag struct {
// Name is the flag name: the field's JSON name with _ written as -.
Name string
// JSON is the field's JSON name, the key the input is sent under.
JSON string
// Kind is the field's kind: string, bool, int, float, or map for a
// map[string]string, which takes key=value.
Kind reflect.Kind
// Usage is the field's doc tag.
Usage string
// Required is set when the field's validate tag has required.
Required bool
// Index is the field's index in the input type.
Index int
}
Flag is one CLI flag derived from an input field.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package commandtest runs a behavior's generated commands for the gen/cli_public_test.go each one gets, with the SDK call faked.
|
Package commandtest runs a behavior's generated commands for the gen/cli_public_test.go each one gets, with the SDK call faked. |