{"modulePath":"github.com/osapi-io/osapi","version":"v0.3.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package command\n\nPackage command is the command layer of the CLI, and the DSL of its local commands. A group's gen/cli.go makes one cobra command for each method and registers it here: Attach puts the commands of the endpoint groups and the behaviors under osapi client, and AttachLocal puts the commands of the local groups under osapi. A local group, which Define makes, runs in the CLI and calls no API: Run checks its input and calls its handler. The layer that sends an endpoint command's request gives the answer to Output, as Run gives a local method's output, and Output prints it: as JSON for --json, or from the method's output type, by the output style of the CLI. No command writes its own output.\n\n## Constants\n\n```go\nconst (\n\t// RenderHidden leaves the field out of the output. --json has it.\n\tRenderHidden = \"-\"\n\t// RenderBytes prints a number of bytes as a size, such as 3.4 GB.\n\tRenderBytes = \"bytes\"\n\t// RenderAge prints the time since a time, or a number of seconds, such\n\t// as 3s.\n\tRenderAge = \"age\"\n\t// RenderTime prints a time in the one time format of the CLI.\n\tRenderTime = \"time\"\n\t// RenderDuration prints a duration: a Go duration, as a string or as a\n\t// number of nanoseconds.\n\tRenderDuration = \"duration\"\n\t// RenderDurationMs prints an integer of milliseconds as a duration.\n\tRenderDurationMs = \"duration=ms\"\n\t// RenderStatus prints a status word in its color.\n\tRenderStatus = \"status\"\n\t// RenderBody makes the field the whole output, as it is: a document,\n\t// such as the text of a skill. The other fields are only in --json.\n\tRenderBody = \"body\"\n\t// RenderShort is the prefix of short=N, which prints the first N\n\t// characters, with ... after them.\n\tRenderShort = \"short=\"\n)\n```\nThe values of the render tag of an output field.\n\n```go\nconst (\n\tKindDefinition = \"definition\"\n\tKindOption     = \"option\"\n\tKindMethod     = \"method\"\n\tKindRefine     = \"refine\"\n\tKindTag        = \"tag\"\n\tKindOutput     = \"output\"\n\tKindWiring     = \"wiring\"\n\tKindDeps       = \"deps\"\n\tKindCheck      = \"check\"\n\tKindGenerated  = \"generated\"\n)\n```\nThe kinds of term in Spec, in the order that a group is written.\n\n```go\nconst (\n\tRuleName     = \"name\"\n\tRuleMethods  = \"methods\"\n\tRuleUnique   = \"unique\"\n\tRuleVerb     = \"verb\"\n\tRuleRoot     = \"root\"\n\tRuleHelp     = \"help\"\n\tRuleFlag     = \"flag\"\n\tRuleDoc      = \"doc\"\n\tRuleValidate = \"validate\"\n\tRuleFails    = \"fails\"\n\tRuleHandler  = \"handler\"\n\tRuleTag      = \"tag\"\n\tRuleSays     = \"says\"\n\tRuleSubDoc   = \"subdoc\"\n\tRulePrints   = \"prints\"\n\t// RuleSecret: a secret.Value input field is not tagged telemetry:\"attr\".\n\tRuleSecret = \"secret\"\n)\n```\nThe rules Validate checks, by the name a Problem reports.\n\n```go\nconst SecretHelp = \" (a secret: secret://\u003cvault\u003e/\u003ckey\u003e, or - to read it from standard input)\"\n```\nSecretHelp is what the help of a secret flag adds: the forms it takes.\n\n```go\nconst SecretsHelp = \" (secrets: NAME=secret://\u003cvault\u003e/\u003ckey\u003e)\"\n```\nSecretsHelp is what the help of a flag of a map of secrets adds.\n\n```go\nconst Stdin = \"-\"\n```\nStdin is the value of a secret flag that reads its value from standard input.\n\n```go\nconst SubKey = \"osapi.endpoint.sub\"\n```\nSubKey is the annotation of a generated command that goes under a command of its own: the Sub segment of its method, such as trace in osapi client telemetry trace get.\n\n```go\nconst TableBlocks = \"blocks\"\n```\nTableBlocks is the table tag of a list whose items print as blocks of paragraphs: a list of long text, such as the terms of a DSL, which the cells of a table would cut.\n\n```go\nconst TableSections = \"sections\"\n```\nTableSections is the table tag of a list whose items print as sections: each item's first field is its heading, and the rest prints under it as an object does, with each list in it as a table or blocks.\n\n## Variables\n\n```go\nvar Absent any = absent{}\n```\nAbsent is the Want of a Field that must not be in the output, such as the value of a secret, which a read never shows.\n\n```go\nvar Actions = map[string]bool{\n\t\"admit\": true, \"reject\": true, \"revoke\": true, \"drain\": true, \"undrain\": true, \"retry\": true,\n\t\"export\": true, \"exec\": true, \"shell\": true, \"start\": true, \"stop\": true,\n\t\"restart\": true, \"enable\": true, \"disable\": true, \"install\": true,\n\t\"uninstall\": true, \"upload\": true, \"deploy\": true, \"undeploy\": true,\n\t\"pull\": true, \"signal\": true, \"reboot\": true, \"shutdown\": true, \"ping\": true,\n\t\"status\": true, \"fingerprint\": true, \"liveness\": true, \"ready\": true,\n\t\"generate\": true, \"validate\": true, \"setup\": true, \"rotate\": true,\n\t\"reveal\": true,\n}\n```\nActions are the commands that do something a CRUD verb does not say. Add one here only for a real action, never for a noun: list the noun's items with list under it instead, such as agent facts list.\n\n```go\nvar Checks = guide.Checks{\n\t{\n\t\tRule:     RuleName,\n\t\tRequires: \"The group, each word of Under, each method and each Sub have a name of lowercase letters and digits, starting with a letter.\",\n\t\tFix:      \"Name the group for what its commands are about, such as token, and each method for what it does, such as generate.\",\n\t},\n\t{\n\t\tRule:     RuleMethods,\n\t\tRequires: \"The group has at least one method.\",\n\t\tFix:      \"Add a method with command.Method, with its input and output types and its name.\",\n\t},\n\t{\n\t\tRule:     RuleUnique,\n\t\tRequires: \"No two methods of a group have one name.\",\n\t\tFix:      \"Give each method its own name.\",\n\t},\n\t{\n\t\tRule:     RuleVerb,\n\t\tRequires: \"The last word of each command is a verb (list, get, create, update, delete) or an action in command.Actions, as TestCommandShape holds each command to.\",\n\t\tFix:      \"Name the method for a verb, and put a noun before it with .Sub, such as key fingerprint. Add a word to command.Actions only for a real action, never for a noun.\",\n\t},\n\t{\n\t\tRule:     RuleRoot,\n\t\tRequires: \"A command goes where it runs and what it touches. Its first word is one of command.RootGroups: controller, agent or nats for the process or the files of that component on this host, config for the config that each component reads, dsl for the definitions of osapi, skill for the skills in the binary, sdk for the Go SDK in the binary, and client for a call to the API. A local group calls no API, so it is never under client. Only start and version are commands of the root itself.\",\n\t\tFix:      \"Put the group Under the command.Parent of the component whose process or files it works on, or of dsl for a command for authors. Add a word to command.RootGroups only as a decision of the owner, recorded in the specs cli.md.\",\n\t},\n\t{\n\t\tRule:     RuleHelp,\n\t\tRequires: \"Each method has a Short, and a method with input has an Example. Each flag that an Example names is a flag of the command: a field of its input, a key that its Flag names, or --json, --debug or --osapi-file.\",\n\t\tFix:      \"Add .Short(\\\"\u003cwhat it does\u003e\\\") and .Example(\\\"--flag value\\\") to the method, and spell each flag of an example as the command has it.\",\n\t},\n\t{\n\t\tRule:     RuleFlag,\n\t\tRequires: \"Each value is a flag: the input is a struct, each field has a json name that is its flag with _ as -, no flag or in tag, and a type a flag holds (string, bool, int, []string, map[string]string, []byte, secret.Value, map[string]secret.Value, or a named string type of a closed set, such as command.Parent). A command takes no positional argument.\",\n\t\tFix:      \"Make the input a struct, tag each field json:\\\"name\\\", drop the flag and in tags, and use one of the flag types.\",\n\t},\n\t{\n\t\tRule:     RuleSecret,\n\t\tRequires: \"No secret.Value input field is tagged telemetry:\\\"attr\\\": a span is no place for a secret. A secret flag takes a reference, secret://\u003cvault\u003e/\u003ckey\u003e, or - to read the value from standard input, and the command resolves a reference itself.\",\n\t\tFix:      \"Remove telemetry:\\\"attr\\\" from the secret field.\",\n\t},\n\t{\n\t\tRule:     RuleDoc,\n\t\tRequires: \"Each input field has a doc tag: the help of its flag.\",\n\t\tFix:      \"Add doc:\\\"...\\\" to the field: a capital letter first and no period at the end.\",\n\t},\n\t{\n\t\tRule:     RuleValidate,\n\t\tRequires: \"Each input field has a validate tag: its rules, or omitempty for an optional field with none. Run checks the value against it before the handler runs, and a value that breaks it is a usage error.\",\n\t\tFix:      rule.Fix,\n\t},\n\t{\n\t\tRule:     RuleFails,\n\t\tRequires: \"Each rule of an input field has a .Fails input that breaks it, which the command refuses with a usage error, required included. A min of 1 on a string that is required or optional needs none: its only bad value is empty.\",\n\t\tFix:      rule.FailsFix,\n\t},\n\t{\n\t\tRule:     RuleSubDoc,\n\t\tRequires: \"Each Sub segment that makes a command of its own, such as method in osapi dsl behavior method get, has a SubDoc: the one line of help of that command.\",\n\t\tFix:      \"Add command.SubDoc(\\\"segment\\\", \\\"...\\\") to Define, with what the segment's commands do, such as Show one method of a behavior in full.\",\n\t},\n\t{\n\t\tRule:     RuleHandler,\n\t\tRequires: \"The group Uses a type, and each method has a handler, func(context.Context, D, In) (Out, error), with D that type and In and Out the method's types.\",\n\t\tFix:      \"Add command.Uses[Deps]() to Define, and .Handle(fn) to each method, with the signature that the message names.\",\n\t},\n\t{\n\t\tRule:     RuleTag,\n\t\tRequires: \"Each tag key of an output field is one of command.KnownTags. Each render tag is one the output knows: -, bytes, age, time, duration, duration=ms, status or short=N with N above 0. An empty tag is on a list, and a title tag is on the blank field _ of the output type.\",\n\t\tFix:      \"Use a render value that osapi dsl command spec get lists, put empty on a list field, and put title on a field _ struct{} of the output type.\",\n\t},\n\t{\n\t\tRule:     RuleSays,\n\t\tRequires: \"A method that answers with no body says what occurred: its name has a past tense, such as admitted for admit, or .Says gives the text.\",\n\t\tFix:      \"Add .Says(\\\"\u003cstate\u003e\\\") to the method, such as .Says(\\\"draining\\\") for drain.\",\n\t},\n\t{\n\t\tRule:     RulePrints,\n\t\tRequires: \"Each method that prints a body, and is not a process, has an Example that Prints gives its output: a value of the method's output type, which its docs page shows as the CLI prints it. Each process has an Example that Logs gives the lines it writes when it starts, which its docs page shows as its log handler writes them. Prints and Logs follow the Example that they show.\",\n\t\tFix:      \"Add .Prints(sample) after the Example that it shows, with sample a value of the method's output type, in samples.go of the group. For a process, add .Logs(lines...) after its Example, with the lines in samples.go of the group.\",\n\t},\n}\n```\nChecks are the rules Validate applies. osapi dsl command validate --help prints each one, and each problem carries the fix of its rule, so an author or an agent can read the rules before breaking one. The tests trigger each rule, and fail on a rule without a check.\n\n```go\nvar KnownTags = []string{\n\t\"before\", \"default\", \"doc\", \"empty\", \"example\", \"flag\", \"in\", \"json\", \"label\",\n\t\"mapstructure\", \"none\", \"param\", \"pattern\", \"prefix\", \"render\",\n\t\"short\", \"table\", \"telemetry\", \"template\", \"title\", \"validate\", \"yaml\",\n}\n```\nKnownTags are the struct tag keys that a field of an input or an output of a command, a behavior or an endpoint can carry: the DSLs, the validator, the output's renderer and the settings loader read them. A key outside the list is a typo: Go reads a tag only by its exact key, so the field gets nothing from it.\n\n```go\nvar RootGroups = []RootGroup{\n\t{Name: \"start\", Purpose: \"Start each component of osapi on this host\", Leaf: true},\n\t{Name: \"version\", Purpose: \"Show the version of this binary\", Leaf: true},\n\t{\n\t\tName:    \"controller\",\n\t\tPurpose: \"Run the controller on this host, and work on its key, its tokens and its roles\",\n\t},\n\t{Name: \"agent\", Purpose: \"Run the agent on this host, and work on its key\"},\n\t{\n\t\tName:    \"nats\",\n\t\tPurpose: \"Run the embedded NATS server on this host, or prepare a NATS server\",\n\t},\n\t{\n\t\tName:    \"pki\",\n\t\tPurpose: \"List and rotate the keys and the TLS certificates of osapi on this host\",\n\t},\n\t{Name: \"config\", Purpose: \"List, get and validate the config that each component reads\"},\n\t{\n\t\tName:    \"skill\",\n\t\tPurpose: \"Show the agent skills in this binary, and install them into a repository\",\n\t},\n\t{\n\t\tName:    \"sdk\",\n\t\tPurpose: \"List, describe and check the Go SDK in this binary: its types and its services\",\n\t},\n\t{Name: \"dsl\", Purpose: \"Describe, check and document the definitions of osapi, for authors\"},\n\t{Name: \"client\", Purpose: \"Call the API of the controller\"},\n}\n```\nRootGroups are the words directly under osapi, a closed list. A command goes where it runs and what it touches: client for a call to the API, controller, agent or nats for the process or the files of that component on this host, config for the config that each component reads, dsl for the definitions of osapi, skill for the skills in the binary, and sdk for the Go SDK in the binary. Only start and version act on the whole binary or host. TestCommandShape fails on any other word. A new word is a decision of the owner, recorded in the specs cli.md.\n\n```go\nvar ShutdownTimeout = 10 * time.Second\n```\nShutdownTimeout is how long a process's components have to stop, after its context ends.\n\n```go\nvar Spec = guide.Spec{\n\tKinds: []guide.Kind{\n\t\t{Kind: KindDefinition, Title: \"Definition\"},\n\t\t{Kind: KindOption, Title: \"Options of Define\"},\n\t\t{Kind: KindMethod, Title: \"Methods\"},\n\t\t{Kind: KindRefine, Title: \"Refinements of a method\"},\n\t\t{Kind: KindTag, Title: \"Tags on input fields\"},\n\t\t{Kind: KindOutput, Title: \"Output, from the output type\"},\n\t\t{Kind: KindDeps, Title: \"What a Deps takes\"},\n\t\t{Kind: KindWiring, Title: \"Wiring\"},\n\t\t{Kind: KindCheck, Title: \"What holds a group to its rules\"},\n\t\t{Kind: KindGenerated, Title: \"Generated, never edited\"},\n\t},\n\tTerms: []guide.Term{\n\t\t{\n\t\t\tKind: KindDefinition,\n\t\t\tName: `Register(Define(name, doc, options...))`,\n\t\t\tDoes: \"Declares a group of local commands and adds it to the registry. A local command runs in the CLI process and calls no API, such as osapi controller token generate. Its command is osapi \u003cname\u003e, and doc is its help.\",\n\t\t\tWhen: \"One time, in \u003cgroup\u003e.go under internal/cli/commands/\u003cgroup\u003e: var Group = command.Register(command.Define(...)). Add its import to internal/cli/commands/all. A command that calls the API is an endpoint or a behavior, not a local command.\",\n\t\t},\n\n\t\t{\n\t\t\tKind: KindOption,\n\t\t\tName: \"Uses[Deps]()\",\n\t\t\tDoes: \"Names the struct of what the group's methods use, such as the config, the file system or the signing of tokens. The CLI gives one with Provide when a command runs, and a test gives one with fakes.\",\n\t\t\tWhen: \"In each group. Keep it to interfaces, so a test can fake each one. An empty struct needs no wiring.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindOption,\n\t\t\tName: `Long(\"text\")`,\n\t\t\tDoes: \"Is the rest of the help of the group's command, after its one line. A method's .Long is the help of its own command.\",\n\t\t\tWhen: \"When the group's command needs more than its one line, such as what each of its commands reads.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindOption,\n\t\t\tName: `Fail()`,\n\t\t\tDoes: \"Is the error a handler returns with its output when the output says what failed, such as the problems of a config: return out, command.Fail(). The output prints as it does on success, then the command exits 1 with no message of its own.\",\n\t\t\tWhen: \"For a check whose answer is the report, such as config validate, so a script or CI fails on it. For any other failure, return the error itself.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindOption,\n\t\t\tName: `Config(\"prefix\", T{...})`,\n\t\t\tDoes: \"Declares that the group owns the section prefix of osapi's config, such as controller, with a value of the section's type whose fields are the defaults of its keys. Each field becomes a key of osapi config list, with its environment variable and its default from here, as a behavior's settings come from behavior.Config.\",\n\t\t\tWhen: \"For a process group, such as controller start, which owns the section that its process reads. A default lives here, never in a central file; a key with no default is a choice of the operator and says why with a choice tag.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindOption,\n\t\t\tName: `Flat()`,\n\t\t\tDoes: \"Makes the group add no word of its own: each method is a command under the group's parent, the root or the words of Under. A command directly under the root is a leaf of command.RootGroups, such as version; any other has a verb or an action. The group's name stays its identity, for dsl command get --name and its package.\",\n\t\t\tWhen: \"For a command that stands alone, such as osapi version, or that goes under a parent that holds other things, such as osapi controller start. Not for a family of commands under one noun, such as token.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindOption,\n\t\t\tName: `SubDoc(\"segment\", \"short\")`,\n\t\t\tDoes: \"Is the one line of help of the command that a Sub segment makes, such as roles in osapi controller role list. validate fails a Sub segment that makes a command and has none.\",\n\t\t\tWhen: \"For each Sub segment of the group whose word is not the method's.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindOption,\n\t\t\tName: `Under(Parent, ...)`,\n\t\t\tDoes: \"Puts the group's command under the command of the words, such as ParentController for osapi dsl endpoint. Use a Parent constant: validate refuses a word outside KnownParents, because Attach makes a word that has no command, so a misspelled word was a new command with no error. Attach uses a hand-written command that cmd/commands.go names.\",\n\t\t\tWhen: \"When the commands belong to a command that is there already, such as controller. Without it, the group is under the root.\",\n\t\t},\n\n\t\t{\n\t\t\tKind: KindMethod,\n\t\t\tName: `Process(\"name\")`,\n\t\t\tDoes: \"A command, osapi \u003cgroup\u003e \u003cname\u003e, that runs a process until the command's context ends, such as osapi nats start. It has no input and no output type; .Setup sets what it runs, and .Logs gives its page the lines that it writes when it starts. The context is the one the root makes and cancels on SIGINT or SIGTERM.\",\n\t\t\tWhen: \"For a command that starts a component and runs until a signal. Its name is an action, such as start.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindMethod,\n\t\t\tName: `.Setup(fn)`,\n\t\t\tDoes: \"Is func(ctx context.Context, d D) (command.Running, error): it makes the process's components with ctx, the command's context, so a signal stops a setup that waits. Running is the components, each with Start() and Stop(ctx), and a Cleanup. command.Serve starts them, waits until ctx ends, stops them together, then runs Cleanup; the stop and the cleanup get context.WithoutCancel(ctx), which keeps its values, with command.ShutdownTimeout, 10 seconds. An error is the command's error, and it exits 1.\",\n\t\t\tWhen: \"On each Process, in place of .Handle. Make each component in Setup and start nothing: Serve starts them.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindMethod,\n\t\t\tName: `Then(running, fn)`,\n\t\t\tDoes: \"Is running with fn after its Cleanup, such as the stop of a tracer, which flushes what the components recorded as they stopped.\",\n\t\t\tWhen: \"In a Setup that wraps the components of another, such as osapi start, which runs the NATS server, the controller and the agent under one tracer.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindMethod,\n\t\t\tName: `.Flag(\"key\", ...)`,\n\t\t\tDoes: \"Adds a flag to a process for each config key, such as agent.max_jobs: --agent-max-jobs, the key with its dots and underscores as dashes, as OSAPI_AGENT_MAX_JOBS is its environment variable. The flag has the key's type, default and doc, from the config, and sets the key over the environment and the file.\",\n\t\t\tWhen: \"On a Process, for each key a person sets when they start it. A Method's flags are its input, so it has no Flag.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindMethod,\n\t\t\tName: `Method[In, Out](\"name\")`,\n\t\t\tDoes: \"A command, osapi \u003cgroup\u003e \u003cname\u003e, that takes In and prints Out. Each field of In is a flag. Out prints as JSON with --json, and from its type without it, by the output style of the CLI.\",\n\t\t\tWhen: \"For each command of the group. Its name is the command's last word: a verb (list, get, create, update, delete) or an action in command.Actions, never a noun.\",\n\t\t},\n\n\t\t{\n\t\t\tKind: KindRefine,\n\t\t\tName: \".Handle(fn)\",\n\t\t\tDoes: \"Sets the function that runs the command: func(ctx context.Context, d Deps, in In) (Out, error). The generated command reads the flags into In, checks it against its validate tags, and calls it. An error from it prints, and the command exits 1.\",\n\t\t\tWhen: \"On each method. Validate checks the signature.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindRefine,\n\t\t\tName: `.Short(\"text\")`,\n\t\t\tDoes: \"Sets the command's one line of help. It starts with a capital letter and has no period at the end; a test of every command holds this.\",\n\t\t\tWhen: \"On each method.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindRefine,\n\t\t\tName: `.Long(\"text\")`,\n\t\t\tDoes: \"Sets the rest of the command's help, in sentences.\",\n\t\t\tWhen: \"When a person needs more than the one line, such as what the command reads.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindRefine,\n\t\t\tName: `.Example(\"--flag value\", \"doc\")`,\n\t\t\tDoes: \"Adds an example of the command: the flags after osapi \u003cgroup\u003e \u003cmethod\u003e, and, when given, what it shows, as a # line above it. The help and the CLI page show each one.\",\n\t\t\tWhen: \"At least one for each method with input: the call a person makes most.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindRefine,\n\t\t\tName: `.Prints(sample)`,\n\t\t\tDoes: \"Gives the last Example its output: a value of the method's output type, which the CLI page shows as the CLI prints it, and as JSON for --json. The page of a method with no output shows its one line for each example, from the example's flags, with no Prints.\",\n\t\t\tWhen: \"After the Example that it shows, on each method that prints a body and is not a process: validate fails one with no Prints. Put the sample in samples.go of the group, with each time in UTC.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindRefine,\n\t\t\tName: `.Check(\"words\", \"flags\", path, want, ...)`,\n\t\t\tDoes: \"Gives the last Example a read that shows its result: the command words after the binary, its flags, and pairs of a path in its --json output and the value that the path must have. A path is JSON names joined with a dot, and a segment [name=value] selects an element of a list. command.Absent is a field that must not be there, and command.OneOf a field that may have any of its values. {out.\u003cpath\u003e} is a field of the example's own --json output. The integration suite runs the read after the example, again for up to 30 seconds until it matches.\",\n\t\t\tWhen: \"After each Example of a write: the integration gate fails a write example with no Check, CheckFails or NoCheck.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindRefine,\n\t\t\tName: `.CheckFails(\"words\", \"flags\", \"text\")`,\n\t\t\tDoes: \"Gives the last Example a read that must fail with text in its error, such as not found: the example removed the thing that the read names.\",\n\t\t\tWhen: \"After each Example of a delete or a revoke.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindRefine,\n\t\t\tName: `.NoCheck(\"why\")`,\n\t\t\tDoes: \"Says why no read shows the result of the method's examples. The integration gate takes it in place of a Check, and requires a reason of 40 characters or more.\",\n\t\t\tWhen: \"Only on a write whose result no osapi command reads back, such as the streams that nats setup makes.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindRefine,\n\t\t\tName: `.Logs(lines...)`,\n\t\t\tDoes: \"Gives the last Example of a process the lines that it writes when it starts, each a command.LogLine: a level, a message and its attributes. The CLI page shows them as the log handler of the CLI writes them in a terminal, in color, and as JSON for --json.\",\n\t\t\tWhen: \"After the Example of each process: validate fails a process with no Logs, and Logs on a method. Put the lines in samples.go of the group, copied from a real start at the info level.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindRefine,\n\t\t\tName: `.Sub(\"segment\")`,\n\t\t\tDoes: \"Puts the command under a command of its own in the group: osapi \u003cgroup\u003e \u003csegment\u003e \u003cmethod\u003e, such as controller role list. The method's identity is its segment and its name, so a group can have get and spec get.\",\n\t\t\tWhen: \"When the command is about a noun of the group: the noun is the Sub, and the method is the verb.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindRefine,\n\t\t\tName: `.Says(\"state\")`,\n\t\t\tDoes: \"Sets what the one line of a method with no output says, after the key of the input: a state, such as draining. Without it, the line says the past tense of the method, such as admitted for admit. An endpoint method has the same refinement.\",\n\t\t\tWhen: \"On a method with no output whose result is a state, not the past tense of its name. validate fails a method with no output, no past tense and no Says.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindRefine,\n\t\t\tName: `.Fails(\"doc\", in)`,\n\t\t\tDoes: \"Declares an input that the command refuses with a usage error, exit code 2: the method's input, with the other fields valid and one rule broken. TestRefusals in internal/cli/commands/all runs each one.\",\n\t\t\tWhen: \"For each rule of each input field, required included, as validate requires.\",\n\t\t},\n\n\t\t{\n\t\t\tKind: KindTag,\n\t\t\tName: `json:\"name\"`,\n\t\t\tDoes: \"Names the field, its flag (with _ as -) and its key in the JSON of the output.\",\n\t\t\tWhen: \"On each field.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindTag,\n\t\t\tName: \"secret.Value\",\n\t\t\tDoes: \"Not a tag: the type of an input field that holds a secret, from internal/secret; map[string]secret.Value is a map of them. Its flag takes a reference, secret://\u003cvault\u003e/\u003ckey\u003e, or - to read the value from standard input; a map flag takes NAME=secret://\u003cvault\u003e/\u003ckey\u003e. The command refuses a literal value, which the shell history keeps. Its String, Format, MarshalJSON and LogValue give the reference or [redacted]; Reveal gives the value. Run refuses a reference until the config has a vault. The secret rule refuses one with telemetry:\\\"attr\\\".\",\n\t\t\tWhen: \"On each input that holds a password, a key or a token. Not a string: a string whose name is on the audit denylist fails TestSecretsAreTyped.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindTag,\n\t\t\tName: `doc:\"...\"`,\n\t\t\tDoes: \"Is the help of the field's flag. A rule of oneof adds its values in brackets.\",\n\t\t\tWhen: \"On each input field: a capital letter first and no period at the end.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindTag,\n\t\t\tName: `short:\"r\"`,\n\t\t\tDoes: \"Gives the field's flag a one-letter shorthand, such as -r.\",\n\t\t\tWhen: \"When the CLI uses that shorthand for the flag elsewhere.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindTag,\n\t\t\tName: `default:\"value\"`,\n\t\t\tDoes: \"Gives the field's flag its value when the caller gives none. A field with a default is never a required flag.\",\n\t\t\tWhen: \"For an option with a value that most calls use.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindTag,\n\t\t\tName: rule.TagName,\n\t\t\tDoes: \"The rules of the value, which Run checks before the handler runs: a value that breaks one is a usage error that names the flag, and the command exits 2. required makes the flag required. The rules are those of internal/validation, which endpoints and behaviors use; dive applies the rules after it to each value of a []string. A custom rule, such as permission, is declared with rule.Declare.\",\n\t\t\tWhen: rule.TagWhen,\n\t\t},\n\t\t{\n\t\t\tKind: KindTag,\n\t\t\tName: \"the type of a field\",\n\t\t\tDoes: \"Is the kind of its flag: a string, a bool, an int, a []string (a flag given once for each value, or with commas), a map[string]string (key=value pairs) or a []byte (the path of a local file, whose content the field gets).\",\n\t\t\tWhen: \"Pick the type of the value a person types.\",\n\t\t},\n\n\t\t{\n\t\t\tKind: KindOutput,\n\t\t\tName: \"Render(p, group, out)\",\n\t\t\tDoes: \"Prints the output of a method through a Printer, as the CLI prints it. The terminal and the pages of the docs site both use it, so a page written from a command's output shows what the command shows.\",\n\t\t\tWhen: \"To write an output somewhere other than the terminal, such as a page of the reference.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindOutput,\n\t\t\tName: \"a list: Items []T, with TotalItems or not, or []T\",\n\t\t\tDoes: \"Prints a heading with the count, such as Files (6):, then a table with one column for each field of T. A list with fewer items than TotalItems counts as (3 of 120). An empty list prints its heading with (0), then None. and the hint of its empty tag.\",\n\t\t\tWhen: \"For each method that returns a list. Name the fields Items and TotalItems, and add no other field.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindOutput,\n\t\t\tName: \"one object\",\n\t\t\tDoes: \"Prints a heading, then an aligned key-value block, one pair for each field. An object in it is a section under the block, with its label as the heading. A list in it is a table under the block, with its count. An object with one field that is an object or a list is an envelope: the value of the field prints, and the envelope does not.\",\n\t\t\tWhen: \"For each method that returns one thing.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindOutput,\n\t\t\tName: \"no output\",\n\t\t\tDoes: \"A method whose output type has no field, such as struct{}, or whose answer has no body (204), prints one line: the key of the input and what occurred, such as m-1 admitted. With --json, it prints nothing.\",\n\t\t\tWhen: \"For a write with nothing to return. The text is the past tense of the method, or what .Says gives.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindOutput,\n\t\t\tName: \"the rules with no options\",\n\t\t\tDoes: \"The columns and the keys have the order of the fields. A field with omitempty or omitzero and no value is not shown. A bool is yes or no. A float32 or float64 has two decimals, such as 0.00. A []string is its values, joined with commas. A time.Time is in the one time format of the CLI. A label is the json name in sentence case, with an initialism such as ID in capitals: machine_id is Machine ID. A column header is the label in capitals. A table leaves out a column that has no value in any row. In a table cell, an object is its values, with a space between them, such as Ubuntu 24.04. A list of objects is the first field of each, with commas, such as HighLoad, DiskPressure. The heading is the name of the group in sentence case, with s for a list.\",\n\t\t\tWhen: \"To change the order of the output, change the order of the fields.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindOutput,\n\t\t\tName: `render:\"-|bytes|age|time|duration|duration=ms|status|short=N|body\"`,\n\t\t\tDoes: \"Changes how a field prints: - leaves it out (--json has it), bytes is a size such as 3.4 GB, age is the time since a time or a number of seconds, time is a time as text in the one time format, duration is a Go duration, duration=ms is an integer of milliseconds as a duration, status is a status word in its color, short=N is the first N characters with ... after them, in a table only: a key-value block shows all of the value, and body makes the field the whole output, as it is, such as the text of a document; the other fields are only in --json.\",\n\t\t\tWhen: \"On an output field whose raw value a person cannot read at a glance. validate fails a value that is not one of these.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindOutput,\n\t\t\tName: `label:\"...\"`,\n\t\t\tDoes: \"Gives the field a different label, and the column the same text in capitals.\",\n\t\t\tWhen: \"When the json name does not say what the value is to a person, such as Last seen for registered_at.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindOutput,\n\t\t\tName: `none:\"...\"`,\n\t\t\tDoes: \"Is the text of a field with no value: absent, null, empty or a zero time. A field with omitempty and a none tag is shown, with the text. A table keeps a column with a none tag, because no cell of it is empty.\",\n\t\t\tWhen: \"When no value means something, such as never for a time or (deleted) for a hash.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindOutput,\n\t\t\tName: `empty:\"...\"`,\n\t\t\tDoes: \"On a list field: the hint that an empty list prints after None., such as Upload one with osapi client file upload.\",\n\t\t\tWhen: \"On each list that a person can add to, to tell what to do next.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindOutput,\n\t\t\tName: `prefix:\"...\"`,\n\t\t\tDoes: \"Is text in front of each value of the field, such as @fact. in front of a fact key.\",\n\t\t\tWhen: \"When a person types the value with the prefix.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindOutput,\n\t\t\tName: `table:\"-\"`,\n\t\t\tDoes: \"Leaves the field out of a table. The key-value block of a get shows it.\",\n\t\t\tWhen: \"On a field that a list does not need and a get does, such as a reason or a time of each change.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindOutput,\n\t\t\tName: `title:\"...\"`,\n\t\t\tDoes: \"On the field _ struct{} of the output type: a different heading. The blank field is not in the JSON or the spec.\",\n\t\t\tWhen: \"When the name of the group is not what the output is, such as Stale deployments in the file group.\",\n\t\t},\n\n\t\t{\n\t\t\tKind: KindDeps,\n\t\t\tName: \"avfs.VFS\",\n\t\t\tDoes: \"The filesystem, for a command that reads or writes files on the machine where it runs, such as a key or the config. cmd/commands.go gives the real one. A test gives memfs.New(), an in-memory filesystem, and reads what the command wrote from it.\",\n\t\t\tWhen: \"For each file that a command reads or writes. Never the os package, which a test cannot replace.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindDeps,\n\t\t\tName: \"fs.FS\",\n\t\t\tDoes: \"A read-only tree of files, such as the skills and templates that the binary embeds. A test gives fstest.MapFS with the files that it needs.\",\n\t\t\tWhen: \"For files that the binary carries, not files on the host.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindDeps,\n\t\t\tName: \"config.Config, string\",\n\t\t\tDoes: \"The config that osapi read, and plain values such as the path of the config file, a directory or the version. A test gives the value.\",\n\t\t\tWhen: \"For what the command reads and does not change. A value is not a service, so it needs no interface.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindDeps,\n\t\t\tName: \"*slog.Logger\",\n\t\t\tDoes: \"The logger of the process. A test gives slog.New(slog.DiscardHandler).\",\n\t\t\tWhen: \"For a process, such as osapi agent start, that logs while it runs. A command that prints its result returns it as its output instead.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindDeps,\n\t\t\tName: \"*slog.LevelVar\",\n\t\t\tDoes: \"The level of the logger of the process, which the process can change while it runs. The root gives the one that its logger logs at; a test gives new(slog.LevelVar), or nil.\",\n\t\t\tWhen: \"For a process whose level can change at run time, such as osapi agent start, which takes the log level of the controller's config of the agent.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindDeps,\n\t\t\tName: \"func(...)\",\n\t\t\tDoes: \"A function that the CLI gives, such as Behaviors, Validate or NewAgent: it reads the registry of this binary, or makes a part of the process. A test gives a function that returns what the case needs.\",\n\t\t\tWhen: \"For one call, or a constructor. When a test must check the calls that a part gets, make the part an interface, as Agent is, and return it from the function.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindDeps,\n\t\t\tName: \"an interface of the group, in deps.go\",\n\t\t\tDoes: \"A service with methods, such as Tokens, or a part that a constructor returns, such as Agent, Controller and Server. The tests give the mockgen mock from the group's mocks/, from go generate ./internal/cli/commands/\u003cgroup\u003e/mocks.\",\n\t\t\tWhen: \"For a service whose calls a test asserts. Never write a fake by hand: a fake does not fail on a call that the test did not expect.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindDeps,\n\t\t\tName: \"*cobra.Command\",\n\t\t\tDoes: \"The root command of the CLI, for a group that reads the tree of commands, such as docs and dsl command.\",\n\t\t\tWhen: \"Only to read the commands of this binary.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindDeps,\n\t\t\tName: \"another group's Deps\",\n\t\t\tDoes: \"The Deps of a different group, for a command that runs that group's work, as osapi start runs the NATS server, the controller and the agent.\",\n\t\t\tWhen: \"For a command that is several other commands at one time. Each part keeps its own Deps.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindWiring,\n\t\t\tName: \"Provide[Deps](Group, fn)\",\n\t\t\tDoes: \"Gives the group's methods their Deps: fn makes them when a command runs, after osapi read its config. A command of a group whose Deps has a field, and that has no Provide, fails.\",\n\t\t\tWhen: \"In cmd/commands.go, one time for each group whose Deps has a field, with the real config, file system or client.\",\n\t\t},\n\n\t\t{\n\t\t\tKind: KindCheck,\n\t\t\tName: \"Root(word) and RootGroups\",\n\t\t\tDoes: \"Where a command goes. The words under osapi are a closed list, each with its purpose: controller, agent or nats for the process or the files of that component on this host, config for the config that each component reads, dsl for the definitions of osapi, skill for the skills in the binary, sdk for the Go SDK in the binary, and client for a call to the API. Only start and version are commands of the root. A local group calls no API, so it is never under client. Under client, the words follow the API path. dsl command validate refuses a group whose first word is not one of them, under the rule root, and TestCommandShape fails on any other word under osapi.\",\n\t\t\tWhen: \"Before you name a group: put it Under the component whose process or files it works on, or Under dsl for a command for authors. A new word under osapi is a decision of the owner.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindWiring,\n\t\t\tName: \"DescribeRoot(root)\",\n\t\t\tDoes: \"Gives each command under the root the purpose of its word in RootGroups as its help. Thus osapi --help and the CLI page of the docs site list each word with its purpose from one list.\",\n\t\t\tWhen: \"Once, in cmd/root.go, after each group is attached. Write a purpose in RootGroups, not in a Short of a root command.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindCheck,\n\t\t\tName: \"Flaggable(type)\",\n\t\t\tDoes: \"Whether a flag holds a value of the type: string, bool, int, []string, map[string]string, []byte, a file, secret.Value, map[string]secret.Value, or a named string type of a closed set, such as Parent, which the command converts from its string flag. The command generator builds a flag of each, and dsl behavior validate asks it of each CLI behavior's input, so the two agree.\",\n\t\t\tWhen: \"Give an input field one of those types.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindCheck,\n\t\t\tName: \"NamedString(type)\",\n\t\t\tDoes: \"Whether the type is a named type of a closed set: a type of its own whose kind is string, such as Parent, and not secret.Value. A flag of it is a string flag, and the command generator converts the flag's value to the type.\",\n\t\t\tWhen: \"Give an input field the named type of a closed set, and keep its oneof rule, which checks the value.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindCheck,\n\t\t\tName: \"TagProblems(type)\",\n\t\t\tDoes: \"Each output tag, such as render, that the output does not know, in the type and the types it holds: the check that dsl command validate makes of a registered command. dsl behavior validate asks it of each behavior's output, so its author sees the problem in the validator they run.\",\n\t\t\tWhen: \"Use a render value that dsl command spec get lists.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindCheck,\n\t\t\tName: \"osapi dsl command validate\",\n\t\t\tDoes: \"Checks every local group against the rules of a definition, and the output of every group: each output tag is one the output knows, and each method with no output says what occurred. Each problem names the rule and ends with its fix. validate --help lists each rule. go generate fails on a local group that breaks one.\",\n\t\t\tWhen: \"After each change to a group.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindCheck,\n\t\t\tName: \"TestRefusals\",\n\t\t\tDoes: \"Runs each input that a method's Fails declares through Run, as the generated command does, and expects a usage error.\",\n\t\t\tWhen: \"It is in internal/cli/commands/all, and covers each group with no change.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindCheck,\n\t\t\tName: \"TestCommandShape\",\n\t\t\tDoes: \"Holds each command under osapi client, and each command of a local group, to \u003cresource\u003e \u003cverb\u003e, with the verbs and actions of command.Verbs and command.Actions.\",\n\t\t\tWhen: \"It is in cmd/help_style_test.go. A new action goes in command.Actions; a noun does not.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindCheck,\n\t\t\tName: \"go generate ./internal/cli/commands/all\",\n\t\t\tDoes: \"Writes, for each local group, the cobra commands in gen/cli.go, and internal/cli/commands/all/gen, which registers every group's commands. cmd attaches them under the root.\",\n\t\t\tWhen: \"After each change to a group. go-generate-check fails when a gen/ file is stale. Never edit a gen/ file.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindCheck,\n\t\t\tName: \"osapi dsl command create --name \u003cgroup\u003e --description \\\"...\\\" --under \u003cword\u003e\",\n\t\t\tDoes: \"Writes a new group under internal/cli/commands/\u003cgroup\u003e, Under the word of the root that --under names (agent, controller, dsl or nats): a list and a get, an empty Deps, its types and the tests of its methods, and adds its import to internal/cli/commands/all. It builds, validates and passes its tests; command-scaffold-check in just test holds it to that.\",\n\t\t\tWhen: \"To start a new group. Then run go generate ./internal/cli/commands/all and just cli-docs-generate, and change it.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindCheck,\n\t\t\tName: \"osapi dsl command get --name \u003cgroup\u003e\",\n\t\t\tDoes: \"Describes a group, local, endpoint or behavior: each command and its one line of help. A local group's commands also have their flags and the inputs they refuse.\",\n\t\t\tWhen: \"To see a group's commands, and the flags and refusals of a local group.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindCheck,\n\t\t\tName: \"osapi dsl command list\",\n\t\t\tDoes: \"Lists each command of the binary, and the layer that made it: command, endpoint, behavior, or hand-written.\",\n\t\t\tWhen: \"To see what a definition makes, and what is still written by hand in cmd/.\",\n\t\t},\n\n\t\t{\n\t\t\tKind: KindGenerated,\n\t\t\tName: \"internal/cli/commands/\u003cgroup\u003e/gen/\",\n\t\t\tDoes: \"The cobra commands of the group, from go generate ./internal/cli/commands/all.\",\n\t\t\tWhen: \"Change the definition, then generate. A generated file that is wrong is fixed in the definition or in internal/cli/command/gen.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindGenerated,\n\t\t\tName: \"internal/cli/commands/\u003cgroup\u003e/mocks/\",\n\t\t\tDoes: \"The doubles of the group's Deps, from go generate ./internal/cli/commands/\u003cgroup\u003e/mocks.\",\n\t\t\tWhen: \"Run it again after deps.go changes.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindGenerated,\n\t\t\tName: \"internal/cli/commands/all/gen/\",\n\t\t\tDoes: \"The import of each group's gen package, so the CLI registers its commands, from go generate ./internal/cli/commands/all.\",\n\t\t\tWhen: \"Change the definition, then generate.\",\n\t\t},\n\t\t{\n\t\t\tKind: KindGenerated,\n\t\t\tName: \"docs/docs/sidebar/usage/cli/\",\n\t\t\tDoes: \"The CLI pages, from just cli-docs-generate. The page of a local command comes from .Short, .Long, .Example, .Prints, .Logs and each input field's doc.\",\n\t\t\tWhen: \"Change the definition, then generate. Do not write a CLI page by hand.\",\n\t\t},\n\t},\n}\n```\nSpec is every term of the command DSL. osapi dsl command spec get prints it, so an author, or an agent, learns the DSL from the binary that it builds. A test fails on an exported option, method or refinement of this package without an entry.\n\n```go\nvar Verbs = map[string]bool{\n\t\"list\":   true,\n\t\"get\":    true,\n\t\"create\": true,\n\t\"update\": true,\n\t\"delete\": true,\n}\n```\nVerbs are the verbs of a resource: each command is \\\u003cresource\u003e \\\u003cverb\u003e, and a last word that is not one of these is an action in Actions.\n\n## Functions\n\n```go\nfunc AddCommands(\n\tg Group,\n\tcmds ...*cobra.Command,\n)\n```\nAddCommands adds a group's generated commands. Each gen/cli.go calls it from init.\n\n```go\nfunc Attach(\n\tparent *cobra.Command,\n\td Deps,\n\tgroups ...*cobra.Command,\n) error\n```\nAttach adds every registered group's commands under parent, osapi client, and keeps d for the commands to call through. A group goes under the commands of its command path: next node sysctl is under next, then node, which Attach adds when parent does not have them. A group or a command that is among groups, by name, is that one, so the generated commands join a hand-written command of the same name, such as agent with key and status. A local group is not attached here: AttachLocal puts it under the root.\n\n```go\nfunc AttachLocal(\n\troot *cobra.Command,\n\td Deps,\n\tgroups ...*cobra.Command,\n) error\n```\nAttachLocal adds the commands of every registered local group under root, osapi, as Attach does for the groups under osapi client: a group goes under the commands that Under names, such as controller.\n\n```go\nfunc Check(\n\tctx context.Context,\n\tin any,\n) error\n```\nCheck validates in against the validate tags of its fields, as Run does before the handler runs. A value that breaks a rule is a \\*UsageError that names the flag of its field.\n\n```go\nfunc Derive(\n\tp Printer,\n\tg Group,\n\tm Command,\n\tin any,\n\tanswer []byte,\n) error\n```\nDerive prints answer, the JSON that method m of g answered, through p as the CLI prints it from the output type. in is the method's input, for the one line of an answer with no body.\n\n```go\nfunc DescribeRoot(\n\troot *cobra.Command,\n)\n```\nDescribeRoot gives each command directly under root the purpose of its word in RootGroups as its help, so that osapi --help and the CLI page of the docs site list each word with its purpose from one list.\n\n```go\nfunc Done(\n\tg Group,\n\tm Command,\n\tflags string,\n) (any, []byte, bool)\n```\nDone is what method m of g prints for an example with flags, when m answers with no body: the input that the flags give, for the one line that Derive prints, and the JSON that --json prints. ok is false for a method that answers with a body, whose example needs a sample output.\n\n```go\nfunc ExampleFlagProblems(\n\texamples []Example,\n\tflags map[string]bool,\n) []string\n```\nExampleFlagProblems are the flags that examples name and that are not in flags or the flags of each command. A misspelled flag made a docs page show a command that fails. The command DSL and the endpoint DSL both check their examples with it.\n\n```go\nfunc Fail() error\n```\nFail is the error a handler returns with its output when the output says what failed, so that a script or CI fails on it: return out, command.Fail(). The output prints as it does on success, then the command exits 1.\n\n```go\nfunc FlagName(\n\tf reflect.StructField,\n) string\n```\nFlagName is the flag of an input field: its json name, with \\_ as -.\n\n```go\nfunc Flaggable(\n\tt reflect.Type,\n) bool\n```\nFlaggable reports whether a flag can hold a value of type t: the types that the command generator builds a flag for, and a named type of a closed set, such as Parent, which is a string flag that the command converts, and a list of one, such as \\[]types.Role. The behavior DSL asks it, so the two cannot disagree.\n\n```go\nfunc GlobalFlag(\n\tname string,\n) bool\n```\nGlobalFlag reports whether name, without its dashes, is a flag that the root command adds to each command, such as json.\n\n```go\nfunc GroupByArea(\n\tcmd *cobra.Command,\n)\n```\nGroupByArea puts each command under cmd that Attach made for a group in a cobra command group of the group's area, so the help of cmd lists them under the label of each area, in the order of area.All: osapi client node --help lists dns and interface under Networking. A command of no area stays under Additional Commands. Call it after Attach.\n\n```go\nfunc InputFlags(\n\tin reflect.Type,\n) map[string]bool\n```\nInputFlags are the flags of the command of a method whose input is in, as the command generator declares them: each field's flag tag, else its FlagName, and its short tag. A field tagged in:\"body\" that is a struct gives a flag for each of its fields. The keys are the names without the dashes.\n\n```go\nfunc NamedString(\n\tt reflect.Type,\n) bool\n```\nNamedString reports whether t is a named type of a closed set: a type of its own whose kind is string, such as Parent. A secret is not one: a flag reads it as a reference.\n\n```go\nfunc Now() time.Time\n```\nNow is the time that an age is from: the clock, or the fixed time that SetNow gives, so a docs page that shows an age is the same on each run.\n\n```go\nfunc Output(\n\tgroup Group,\n\tmethod string,\n\tin any,\n\tanswer []byte,\n)\n```\nOutput prints the answer of method of group, to the input in. With --json it prints the body as it came, or, for a method that answered with no body, its key and what it did. Without it, a group that a GroupPrinter prints, such as a behavior, prints its way, and each other method prints from its output type.\n\n```go\nfunc PrintsGroups(\n\tp GroupPrinter,\n)\n```\nPrintsGroups adds p, which prints a kind of group. The behavior runtime adds the result table of each behavior.\n\n```go\nfunc Provide[D any](\n\tg *LocalGroup,\n\tfn func() D,\n)\n```\nProvide gives the group's methods their deps: fn makes them when a command runs, after the config is read. D must be the type the group Uses; any other is a mistake in the code, so it panics. A group whose Deps has no field needs none.\n\n```go\nfunc ReadFile(\n\tpath string,\n) ([]byte, bool)\n```\nReadFile is the content of the local file at path, for a flag of a \\[]byte field. A file that it cannot read is reported, and ok is false.\n\n```go\nfunc Render(\n\tp Printer,\n\tname string,\n\tout any,\n) error\n```\nRender prints out, the output of a method of the group name, through p as the CLI prints it: thus a page of the docs site that a markdown printer writes from a command's output shows the same thing as the command.\n\n```go\nfunc RenderTags() []string\n```\nRenderTags are the render tags of an output field, as the CLI and the UI read them. short= takes a number after it, such as short=12.\n\n```go\nfunc Report(\n\terr error,\n)\n```\nReport reports a failed call of the running command, through the Error that Attach got.\n\n```go\nfunc Run(\n\tcmd *cobra.Command,\n\tg *LocalGroup,\n\tmethod string,\n\tin any,\n) error\n```\nRun runs method of g with in, the input that the command's flags made: it checks in against its validate tags, calls the method's handler with the deps that Provide gave, and gives the output to Output, which prints it. An input that breaks a rule is a \\*UsageError, and the handler does not run. The generated command of each local method calls it.\n\n```go\nfunc Scaffold(\n\troot string,\n\tgroup string,\n\tdoc string,\n\tunder Parent,\n) ([]string, error)\n```\nScaffold writes a new local group's layout under internal/cli/commands/\\\u003cname\u003e/ in the osapi checkout at root, Under the word of the root that under names, such as controller, and registers it in internal/cli/commands/all. It returns the files written, relative to root, the registration last. Everything is rendered and checked before anything is written, so a taken name or a root that is not a checkout writes nothing.\n\n```go\nfunc Secret(\n\tcmd *cobra.Command,\n\tname string,\n\tflag string,\n) (secret.Value, bool)\n```\nSecret is the value of the secret flag name, as the command sends it: a reference as it is, or the value that standard input gives for -, with no line break at its end. A literal value is refused, and so is a value from standard input that is empty. A refusal is reported, and ok is false.\n\n```go\nfunc Secrets(\n\t_ *cobra.Command,\n\tname string,\n\tflags map[string]string,\n) (map[string]secret.Value, bool)\n```\nSecrets are the values of the flag name of a map of secrets, each NAME=secret://\\\u003cvault\u003e/\\\u003ckey\u003e. A literal value is refused, as for Secret, and standard input gives one value only, so - is refused too. A refusal is reported, and ok is false.\n\n```go\nfunc Serve(\n\tcmd *cobra.Command,\n\tg *LocalGroup,\n\tmethod string,\n) error\n```\nServe runs the process method of g. The context is the command's: one context, which the root makes and cancels on SIGINT or SIGTERM. Setup gets it, so a signal stops a setup that waits. Serve starts each component, waits until the context ends, then stops the components together, and then runs the cleanup. The stop and the cleanup get the context without its cancel, which keeps its values, with ShutdownTimeout. An error of Setup is the command's error. The generated command of each process calls it.\n\n```go\nfunc SetNow(\n\tt time.Time,\n)\n```\nSetNow fixes the time that an age is from to t, or gives the clock back with the zero time. The generator of the docs pages fixes it.\n\n```go\nfunc SetTraceID(\n\tid string,\n)\n```\nSetTraceID keeps the trace of the call the running command made, for TraceID. The layer that sends the call sets it before Output.\n\n```go\nfunc Strings[T ~string](\n\tvalues []string,\n) []T\n```\nStrings is values as a list of T, for a flag of a \\[]T field whose T is a named string type, such as \\[]types.Role.\n\n```go\nfunc TagKeys(\n\ttag reflect.StructTag,\n) []string\n```\nTagKeys are the keys of tag, in order, by the convention that reflect.StructTag.Get reads: key:\"value\" pairs separated by spaces.\n\n```go\nfunc TagProblems(\n\tt reflect.Type,\n) []string\n```\nTagProblems is each tag of output type t, and of the types it holds, that the output does not know: the check that ValidateOutput makes on a registered command, for a validator that has the type before a command.\n\n```go\nfunc TraceID() string\n```\nTraceID is the trace of the call that the running command made, from the controller's traceresponse header, for a printer that prints it, as each behavior's result table does. It is \"\" when the answer had none.\n\n```go\nfunc WithCheck(\n\texamples []Example,\n\tc ReadBack,\n) bool\n```\nWithCheck adds c to the last of examples, and reports false when there is no example for it to check: the Check of a method came before its Example, which validate refuses.\n\n## Types\n\n```go\ntype Choice []any\n```\nChoice is the Want of a Field that may have any of its values, as OneOf makes it.\n\n```go\nfunc OneOf(\n\tvalues ...any,\n) Choice\n```\nOneOf is the Want of a Field that may have any of values, for a state that moves on its own, such as Draining, which becomes Cordoned when the agent's last job ends.\n\n```go\ntype Column struct {\n\t// JSON is the field's json name, its key in the answer.\n\tJSON string\n\t// Label is the json name in sentence case, or the label tag.\n\tLabel string\n\t// Header is the label in capitals.\n\tHeader string\n\t// Render is the field's render tag, or \"\".\n\tRender string\n\t// None is the text for a field with no value, from the none tag.\n\tNone string\n\t// Empty is the hint after None. for an empty list, from the empty tag.\n\tEmpty string\n\t// Prefix is the text in front of each value, from the prefix tag.\n\tPrefix string\n\t// OmitEmpty is true for a field whose json tag has omitempty or\n\t// omitzero: with no value, it is not shown.\n\tOmitEmpty bool\n\t// NoTable is true for a field tagged table:\"-\": a table leaves it out,\n\t// and a key-value block shows it.\n\tNoTable bool\n\t// Blocks is true for a list tagged table:\"blocks\": each item prints as\n\t// a block of paragraphs, not as a row, for a list of long text.\n\tBlocks bool\n\t// Sections is true for a list tagged table:\"sections\": each item prints\n\t// as a section, headed by its first field, such as a kind of a DSL and\n\t// its terms, since a table cannot show the list each item holds.\n\tSections bool\n\t// NoLabel is true for a field tagged label:\"-\": in a block, its text\n\t// is a paragraph with no label.\n\tNoLabel bool\n\t// Type is the field's type.\n\tType reflect.Type\n}\n```\nColumn is one field of an output type: a column of a table, or a pair of a key-value block.\n\n```go\nfunc Columns(\n\tout reflect.Type,\n) []Column\n```\nColumns are the fields of out that the output shows, in the order of the fields: each exported field with a json name, of out or of its element for a list, except a field tagged render:\"-\".\n\n```go\nfunc (c Column) Format(\n\tp Printer,\n\tv any,\n) string\n```\nFormat is the text of v, the value of the column's field in the answer as JSON decodes it, by its render tag and its type, for a table: short=N cuts it.\n\n```go\nfunc (c Column) FormatKV(\n\tp Printer,\n\tv any,\n) string\n```\nFormatKV is the text of v for a key-value block: as Format, except that short=N does not cut it, because a block has the room for all of it.\n\n```go\ntype Command interface {\n\t// MethodName is the method's name in its group.\n\tMethodName() string\n\t// Input is the type of the method's input: a flag for each field.\n\tInput() reflect.Type\n\t// CommandName is the command's name.\n\tCommandName() string\n\t// SubPath is the command the command goes under in its group, or \"\".\n\tSubPath() string\n\t// CommandShort is the command's one line of help.\n\tCommandShort() string\n\t// CommandLong is the rest of the command's help, or \"\".\n\tCommandLong() string\n\t// Examples are the command's examples.\n\tExamples() []Example\n\t// PageNotes is the Notes section of the command's page, or \"\".\n\tPageNotes() string\n\t// PageResult is the Result section of the command's page, or \"\".\n\tPageResult() string\n\t// Output is the type of the method's output, which the output prints\n\t// from.\n\tOutput() reflect.Type\n\t// KeyField is the json name of the input field that names what the\n\t// command acts on, such as machine_id, or \"\".\n\tKeyField() string\n\t// Saying is what the one line of a method with no body says, which Says\n\t// set, or \"\" for the past tense of the method.\n\tSaying() string\n}\n```\nCommand is one method of a group: one command.\n\n```go\ntype Component interface {\n\t// Start starts the component, and does not block.\n\tStart()\n\t// Stop stops the component, in the time that ctx gives.\n\tStop(ctx context.Context)\n}\n```\nComponent is a part of a process, such as the NATS server or the agent.\n\n```go\ntype Deps struct {\n\t// JSON reports whether --json was given.\n\tJSON func() bool\n\t// Error reports a failed call.\n\tError func(err error)\n\t// PrintJSON prints an answer as it came, for --json.\n\tPrintJSON func(body []byte)\n\t// Print is what the output of a method prints through: the CLI's\n\t// headings, blocks, tables and formats.\n\tPrint Printer\n}\n```\nDeps is what the commands need from the CLI.\n\n```go\ntype Example struct {\n\tFlags string\n\tDoc   string\n\t// Output is what the API answers for the example, a value of the\n\t// method's output type, which Prints sets. The docs page of the command\n\t// shows it as the CLI prints it. Nil shows no output.\n\tOutput any\n\t// Logs are the lines that a process writes when it starts, which Logs\n\t// sets. The docs page of the command shows them as its log handler\n\t// writes them.\n\tLogs []LogLine\n\t// Checks are the reads that show what the example changed, which Check\n\t// and CheckFails add. The integration suite runs each after the example\n\t// and asserts its fields.\n\tChecks []ReadBack\n}\n```\nExample is an example of a CLI command: its flags, and what it shows, which the help writes as a # line above it.\n\n```go\ntype FailedError struct{}\n```\nFailedError is the error of a method whose output says what failed, such as the problems of a config: Run prints the output, then the command exits 1 with no message of its own. Fail returns it.\n\n```go\nfunc (FailedError) Error() string\n```\n\n```go\ntype Field struct {\n\tPath string\n\tWant any\n}\n```\nField is one field of a ReadBack: the path of the field in the --json output, and the value that it must have.\n\nA path is the JSON names of the fields, joined with a dot, such as labels.group. A segment \\[name=value] selects the first element of a list whose field name has value, such as items.\\[id=1a2b3c4d].revoked. Want is compared as JSON: 4 matches 4 and \"4\" does not. Absent is a field, or a selected element, that is not there, and OneOf is a field that may have any of its values.\n\n```go\nfunc Fields(\n\tpathsAndWants ...any,\n) []Field\n```\nFields pairs paths and wants, such as Fields(\"max\\_jobs\", 4, \"log\\_level\", \"debug\"). It panics on an odd count or a path that is not a string: a definition is wrong, and the gate's tests catch it.\n\n```go\ntype Group interface {\n\t// GroupName is the group's command.\n\tGroupName() string\n\t// GroupDoc says what the group is, in one line: its command's help.\n\tGroupDoc() string\n\t// GroupNotes is the Notes section of the page of the group's command,\n\t// or \"\".\n\tGroupNotes() string\n\t// GroupLong is the rest of the help of the group's command, or \"\".\n\tGroupLong() string\n\t// SubDoc is the one line of help of the command that a Sub segment\n\t// makes, such as trace, or \"\".\n\tSubDoc(segment string) string\n\t// CommandPath is the words of the group's command under osapi client,\n\t// such as next node sysctl.\n\tCommandPath() []string\n\t// Commands are the group's methods, in the order they were declared.\n\tCommands() []Command\n\t// CommandPermission is the permission the command of method m needs, or\n\t// \"\" for one that needs none.\n\tCommandPermission(m Command) types.Permission\n}\n```\nGroup is a group of commands, osapi client \\\u003cgroup\u003e, with one command for each of its methods. An endpoint group is one.\n\n```go\nfunc Groups() []Group\n```\nGroups are the registered groups: each endpoint group, behavior and local group whose commands AddCommands added, in the order they were added.\n\n```go\nfunc Origin(\n\tc *cobra.Command,\n) (Group, bool)\n```\nOrigin is the group whose definition made c, a command that Attach or AttachLocal added, and false for a command that a person wrote.\n\n```go\ntype GroupPrinter func(g Group, method string, answer []byte) bool\n```\nGroupPrinter prints the answer of method of group g, and is true, or is false for a group that it does not print.\n\n```go\ntype LocalGroup struct {\n\t// Name is the group's command, the first word under its path.\n\tName string\n\t// Doc says what the group is, in one line: its command's help.\n\tDoc string\n\t// Parents are the words of the command the group goes under, which\n\t// Under sets, such as controller. The root has none.\n\tParents []Parent\n\t// Deps is the type Uses names: what the methods get from the CLI.\n\tDeps reflect.Type\n\t// Methods are the group's commands, in the order they were declared.\n\tMethods []*LocalMethod\n\t// Flat is true for a group that adds no word of its own, which Flat\n\t// sets: its commands are under its parent, such as osapi version.\n\tFlat bool\n\t// Long is the rest of the help of the group's command, which Long\n\t// sets.\n\tLong string\n\t// SubDocs are the one line of help of each command that a Sub makes,\n\t// such as roles in osapi controller role list, which SubDoc sets.\n\tSubDocs map[string]string\n\n\t// ConfigPrefix and ConfigDefaults are the section of the config that the\n\t// group owns, and its defaults, which Config sets.\n\tConfigPrefix   string\n\tConfigDefaults any\n\t// contains filtered or unexported fields\n}\n```\nLocalGroup is a group of local commands: commands that run in the CLI process, with no API, such as osapi controller token generate. Define makes one; its gen/cli.go makes a cobra command for each method, and Run runs it.\n\n```go\nfunc All() []*LocalGroup\n```\nAll is each registered local group, by command path.\n\n```go\nfunc Define(\n\tname string,\n\tdoc string,\n\topts ...Option,\n) *LocalGroup\n```\nDefine builds a local group from its options. Validate checks the result.\n\n```go\nfunc Lookup(\n\tpath string,\n) *LocalGroup\n```\nLookup is the registered local group with the command path, such as token, or nil.\n\n```go\nfunc Register(\n\tg *LocalGroup,\n) *LocalGroup\n```\nRegister adds g to the local groups the CLI has, and returns it. Two groups with one command path are a mistake in the code, so it panics.\n\n```go\nfunc (g *LocalGroup) CommandPath() []string\n```\nCommandPath is the words of the group's command under the root: the words Under set, then its name.\n\n```go\nfunc (g *LocalGroup) CommandPermission(\n\t_ Command,\n) types.Permission\n```\nCommandPermission is \"\": a local command calls no API, so it needs no permission.\n\n```go\nfunc (g *LocalGroup) Commands() []Command\n```\nCommands are the group's methods.\n\n```go\nfunc (g *LocalGroup) GroupDoc() string\n```\nGroupDoc is the group's Doc.\n\n```go\nfunc (g *LocalGroup) GroupLong() string\n```\nGroupLong is the help Long set, or \"\".\n\n```go\nfunc (g *LocalGroup) GroupName() string\n```\nGroupName is the group's Name.\n\n```go\nfunc (g *LocalGroup) GroupNotes() string\n```\nGroupNotes is \"\": a local group's page has no Notes section.\n\n```go\nfunc (g *LocalGroup) Method(\n\tname string,\n) *LocalMethod\n```\nMethod is the method of g with the name, its MethodName, such as get or spec get, or nil.\n\n```go\nfunc (g *LocalGroup) Path() string\n```\nPath is the group's words and its name, such as dsl endpoint, or version for a flat group at the root: the key that Register and Lookup use, and the name that a problem and dsl command get give it.\n\n```go\nfunc (g *LocalGroup) SubDoc(\n\tsegment string,\n) string\n```\nSubDoc is the help SubDoc set for the segment, or \"\".\n\n```go\ntype LocalMethod struct {\n\t// Name is the method's name in its group, and the command's last word.\n\tName string\n\t// In is the input type: each field is a flag.\n\tIn reflect.Type\n\t// Out is the output type, which prints as JSON with --json.\n\tOut reflect.Type\n\t// contains filtered or unexported fields\n}\n```\nLocalMethod is one local command. Method makes one; its methods set the rest and return it, so a definition chains them.\n\n```go\nfunc Method[In, Out any](\n\tname string,\n) *LocalMethod\n```\nMethod is a local command named name that takes In, whose fields are its flags, and prints Out.\n\n```go\nfunc Process(\n\tname string,\n) *LocalMethod\n```\nProcess is a local command named name that runs a process until the context ends, such as osapi nats start: it has no input and no output. Setup sets what it runs.\n\n```go\nfunc (m *LocalMethod) Check(\n\tcommand string,\n\tflags string,\n\tpathsAndWants ...any,\n) *LocalMethod\n```\nCheck gives the last Example a read that shows its result: the command words after the binary, such as pki key get, its flags, and the paths and wants of the fields of its --json output, as command.Fields pairs them. The integration suite runs it after the example. validate refuses a Check before an Example.\n\n```go\nfunc (m *LocalMethod) CheckFails(\n\tcommand string,\n\tflags string,\n\terrorText string,\n) *LocalMethod\n```\nCheckFails gives the last Example a read that fails with errorText, such as not found: the example removed the thing that the read names.\n\n```go\nfunc (m *LocalMethod) CommandLong() string\n```\nCommandLong is the help Long set, or \"\".\n\n```go\nfunc (m *LocalMethod) CommandName() string\n```\nCommandName is the command's name, the method's.\n\n```go\nfunc (m *LocalMethod) CommandShort() string\n```\nCommandShort is the one line Short set.\n\n```go\nfunc (m *LocalMethod) ConfigKeys() []string\n```\nConfigKeys are the config keys that Flag named.\n\n```go\nfunc (m *LocalMethod) Example(\n\tflags string,\n\tdoc ...string,\n) *LocalMethod\n```\nExample adds an example of the command: its flags, such as --name web, and, when doc is given, what it shows, as a # line above it.\n\n```go\nfunc (m *LocalMethod) Examples() []Example\n```\nExamples are the examples Example added.\n\n```go\nfunc (m *LocalMethod) Fails(\n\tdoc string,\n\tinput any,\n) *LocalMethod\n```\nFails declares an input that the command refuses with a usage error: the method's input with the other fields valid and one rule broken. Validate requires one for each rule of each input field, and a test runs each one.\n\n```go\nfunc (m *LocalMethod) Flag(\n\tkeys ...string,\n) *LocalMethod\n```\nFlag adds a flag for each config key, such as agent.max\\_jobs, to a process: --agent-max-jobs, with the key's type, default and doc, which sets the key over the environment and the file.\n\n```go\nfunc (m *LocalMethod) Handle(\n\tfn any,\n) *LocalMethod\n```\nHandle sets the function that runs the command: func(ctx context.Context, d D, in In) (Out, error), with D the type the group Uses. Validate checks the signature; Run calls it.\n\n```go\nfunc (m *LocalMethod) Handler() any\n```\nHandler is the function Handle set, or nil.\n\n```go\nfunc (m *LocalMethod) Input() reflect.Type\n```\nInput is the method's In.\n\n```go\nfunc (m *LocalMethod) IsProcess() bool\n```\nIsProcess is true for a method that Process made.\n\n```go\nfunc (m *LocalMethod) KeyField() string\n```\nKeyField is \"\": a local command acts on no item of an API.\n\n```go\nfunc (m *LocalMethod) Logs(\n\tlines ...LogLine,\n) *LocalMethod\n```\nLogs gives the last Example the lines that a process writes when it starts, at the info level or above. The docs page of the command shows them as its log handler writes them in a terminal, and as JSON for --json. validate refuses Logs before an Example, Logs on a method that is not a process, and a process that no example Logs.\n\n```go\nfunc (m *LocalMethod) Long(\n\ttext string,\n) *LocalMethod\n```\nLong sets the rest of the command's help.\n\n```go\nfunc (m *LocalMethod) MethodName() string\n```\nMethodName is the method's identity in its group: its Sub and its Name, such as roles list, or its Name for a method with no Sub. Two methods of a group can have one Name under two Subs, such as get and spec get.\n\n```go\nfunc (m *LocalMethod) NoCheck(\n\twhy string,\n) *LocalMethod\n```\nNoCheck says why no read shows the result of the method's examples, for a write whose result no command reads back. The integration gate requires a Check of each example of a write, or this.\n\n```go\nfunc (m *LocalMethod) Output() reflect.Type\n```\nOutput is the method's Out, which its output prints from.\n\n```go\nfunc (m *LocalMethod) PageNotes() string\n```\nPageNotes is \"\": a local command's page has no Notes section.\n\n```go\nfunc (m *LocalMethod) PageResult() string\n```\nPageResult is \"\": a local command's page has no Result section.\n\n```go\nfunc (m *LocalMethod) Prints(\n\tout any,\n) *LocalMethod\n```\nPrints gives the last Example its output: what the command prints, a value of the method's output type. The docs page of the command shows it as the CLI prints it, and as JSON for --json. validate refuses a value of another type, Prints before an Example, and a method with output that no example Prints.\n\n```go\nfunc (m *LocalMethod) Refusals() []Refusal\n```\nRefusals are the inputs Fails declared.\n\n```go\nfunc (m *LocalMethod) Saying() string\n```\nSaying is the text Says set, or \"\".\n\n```go\nfunc (m *LocalMethod) Says(\n\ttext string,\n) *LocalMethod\n```\nSays is what the one line of a method with no output says, when it is a state and not the past tense of the method, such as draining for drain.\n\n```go\nfunc (m *LocalMethod) Setup(\n\tfn any,\n) *LocalMethod\n```\nSetup sets the function that makes a process's components: func(ctx context.Context, d D) (command.Running, error), with D the type the group Uses. Serve calls it with the context of the command, then runs what it returns until that context ends.\n\n```go\nfunc (m *LocalMethod) Short(\n\ttext string,\n) *LocalMethod\n```\nShort sets the command's one line of help.\n\n```go\nfunc (m *LocalMethod) Sub(\n\tsegment string,\n) *LocalMethod\n```\nSub puts the command under a command of its own in the group, such as roles in osapi controller role list.\n\n```go\nfunc (m *LocalMethod) SubPath() string\n```\nSubPath is the segment Sub set, or \"\".\n\n```go\nfunc (m *LocalMethod) Unchecked() string\n```\nUnchecked is why no read shows the result of the method's examples, as NoCheck says it, or \"\".\n\n```go\ntype LogLine struct {\n\tLevel slog.Level\n\tMsg   string\n\tAttrs []slog.Attr\n}\n```\nLogLine is a line that a process writes to its log: its level, its message, and its attributes in order, such as component=nats.\n\n```go\ntype Option interface {\n\t// contains filtered or unexported methods\n}\n```\nOption is a setting of a local group, or one of its methods.\n\n```go\nfunc Config(\n\tprefix string,\n\tdefaults any,\n) Option\n```\nConfig declares that the group owns the section prefix of osapi's config, such as controller, with defaults: a value of the section's type whose fields are its keys' defaults. Each field becomes a key of osapi config list, with its environment variable, and its default comes from here, as a behavior's settings come from behavior.Config. A process group, such as controller start, owns the section that its process reads.\n\n```go\nfunc Flat() Option\n```\nFlat makes the group add no word of its own: each method is a command under the group's parent, the root or the words of Under. osapi version is the method version of a flat group at the root; osapi controller start would be the method start of a flat group Under controller. A command directly under the root is a leaf of RootGroups, and any other has a verb or an action.\n\n```go\nfunc Long(\n\ttext string,\n) Option\n```\nLong is the rest of the help of the group's command, after its one line, such as what each of its commands reads.\n\n```go\nfunc SubDoc(\n\tsegment string,\n\tshort string,\n) Option\n```\nSubDoc is the one line of help of the command that the Sub segment makes, such as roles in osapi controller role list.\n\n```go\nfunc Under(\n\twords ...Parent,\n) Option\n```\nUnder puts the group's command under the command of words, such as ParentController for osapi dsl endpoint. Without it, the group is under the root.\n\n```go\nfunc Uses[D any]() Option\n```\nUses names D, the struct of what the group's methods use, such as the config or the signing of tokens. The CLI gives one D with Provide, and a test gives one with fakes. Each handler takes it as its second argument.\n\n```go\ntype Parent string\n```\nParent is a command that local groups go under, such as controller for osapi dsl endpoint. A misspelled parent made a new command at the root with no error, so validate refuses a word outside KnownParents.\n\n```go\nconst (\n\tParentAgent      Parent = \"agent\"\n\tParentController Parent = \"controller\"\n\tParentDSL        Parent = \"dsl\"\n\tParentNATS       Parent = \"nats\"\n\tParentPKI        Parent = \"pki\"\n)\n```\nThe commands that local groups go under.\n\n```go\nfunc KnownParents() []Parent\n```\nKnownParents are the commands that a group can be Under. Add a constant here to make a new one.\n\n```go\nfunc (p Parent) Valid() bool\n```\nValid reports whether p is a command that a group can be Under.\n\n```go\nfunc (Parent) Values() []Parent\n```\nValues are the commands that a group can be Under, for the enum rule.\n\n```go\ntype Printer interface {\n\t// Heading prints the heading of a block.\n\tHeading(title string)\n\t// KV adds labelled values to the key-value block under the heading.\n\tKV(pairs ...string)\n\t// Table prints a table under its heading.\n\tTable(t Table)\n\t// Verdict prints one line at the left margin, such as m-1 admitted.\n\tVerdict(text string)\n\t// Text prints text as it is, such as a document a field holds.\n\tText(text string)\n\t// Block prints one item of a list tagged table:\"blocks\": its title on\n\t// a line, then each pair, a label and a text, as a wrapped paragraph.\n\t// A pair with no label is a paragraph alone.\n\tBlock(title string, pairs ...string)\n\t// Status is a status word in its color.\n\tStatus(word string) string\n\t// Bytes is a size, such as 3.4 GB.\n\tBytes(n int64) string\n\t// Age is the time since something, such as 3s.\n\tAge(d time.Duration) string\n\t// Time is a time in the one time format of the CLI.\n\tTime(t time.Time) string\n\t// Duration is a duration rounded to a useful precision.\n\tDuration(d time.Duration) string\n}\n```\nPrinter is how the output of a method prints: the headings, blocks and tables of the CLI, and the formats of its values. The CLI gives the helpers of internal/cli, which has the one theme, through Deps.\n\n```go\ntype Problem struct {\n\t// Group is the command path of the group it is about.\n\tGroup string `json:\"group\"`\n\t// Method is the method it is about, or \"\" for the group.\n\tMethod string `json:\"method,omitempty\"`\n\t// Rule is the name of the rule, from Checks.\n\tRule string `json:\"rule\"`\n\t// Message says what is wrong.\n\tMessage string `json:\"message\"`\n\t// Fix is how to fix it, from the check of Rule.\n\tFix string `json:\"fix\" table:\"-\"`\n}\n```\nProblem is a rule a definition breaks, and how to fix it.\n\n```go\nfunc Validate(\n\tg *LocalGroup,\n) []Problem\n```\nValidate is each rule g breaks. A group with no problems makes commands that hold to the CLI's rules.\n\n```go\nfunc ValidateOutput() []Problem\n```\nValidateOutput is each rule that the output of a registered group breaks: each group whose commands AddCommands added, endpoint, behavior and local. Each tag of an output type has a value that the output knows, and a method with no body says what occurred.\n\n```go\nfunc (p Problem) String() string\n```\n\n```go\ntype ReadBack struct {\n\t// Command is the words of the read after the binary, such as client\n\t// agent config get.\n\tCommand string\n\t// Flags are the read's flags, such as --hostname web-01.\n\tFlags string\n\t// Fields are the fields of the read's --json output to assert.\n\tFields []Field\n\t// Fails is the text that the read's error contains, in place of\n\t// Fields: the example removed the thing that it reads.\n\tFails string\n}\n```\nReadBack is a read that shows the result of an example: a command, its flags, and the fields of its --json output with the values that they must have, or the text of the error that the read must fail with, for a thing that the example removed.\n\nThe integration suite fills the flags and the values of a check as it fills the example's own: a name that the example uses, such as web-01 or app.conf, becomes the suite's. {out.\\\u003cpath\u003e} is the field at path of the example's own --json output, such as {out.id} for the ID that a create answers.\n\n```go\ntype Refusal struct {\n\t// Doc says what is wrong with the input, such as \"an unknown role\".\n\tDoc string\n\t// Input is the method's input, with one rule broken.\n\tInput any\n}\n```\nRefusal is an input that the command refuses with a usage error, as Fails declares it.\n\n```go\ntype RootGroup struct {\n\t// Name is the word, such as controller.\n\tName string\n\t// Purpose says what goes under the word, in one line: the help of its\n\t// command, and its row on the CLI page of the docs site.\n\tPurpose string\n\t// Leaf is true for a command of the root itself, with no words under\n\t// it, such as version.\n\tLeaf bool\n}\n```\nRootGroup is a word directly under osapi, and what goes under it.\n\n```go\nfunc Root(\n\tword string,\n) (RootGroup, bool)\n```\nRoot is the RootGroup of word, and false for a word that is not one.\n\n```go\ntype Running struct {\n\tComponents []Component\n\tCleanup    func(ctx context.Context)\n}\n```\nRunning is what a process's Setup made: the components that Serve starts and stops, and what it does after they stop, such as flush the traces.\n\n```go\nfunc Then(\n\tr Running,\n\tfn func(ctx context.Context),\n) Running\n```\nThen is r with fn after its cleanup, such as the stop of a tracer, which flushes what the components recorded as they stopped.\n\n```go\ntype Table struct {\n\tTitle   string\n\tHeaders []string\n\tRows    [][]string\n\tEmpty   string\n}\n```\nTable is a table of the output: its heading with the count, the column headers, the rows, and the hint that an empty list prints after None.\n\n```go\ntype UsageError struct {\n\t// Msg says what is wrong, and names the flag.\n\tMsg string\n}\n```\nUsageError is a command that was called wrong, such as a flag whose value breaks a rule of its field. The CLI prints it with a pointer to the help, and exits 2.\n\n```go\nfunc (e *UsageError) Error() string\n```\n\n","path":"github.com/osapi-io/osapi/internal/cli/command","name":"command","synopsis":"Package command is the command layer of the CLI, and the DSL of its local commands.","isRedistributable":true}
