Add generated help and version commands
This commit is contained in:
91
docs/cli.md
Normal file
91
docs/cli.md
Normal file
@@ -0,0 +1,91 @@
|
||||
# Command line reference
|
||||
|
||||
CommandKit owns command routing and syntax for commands registered with its
|
||||
`App`. The caller supplies argv without the executable name, a context, and the
|
||||
output and diagnostic writers. `App.Execute` returns an `Outcome`; it does not
|
||||
exit the process.
|
||||
|
||||
## Help
|
||||
|
||||
The root help command lists registered commands and their summaries. Help is
|
||||
available through a bare invocation, `--help`, `-h`, and `help`:
|
||||
|
||||
```text
|
||||
example
|
||||
example --help
|
||||
example -h
|
||||
example help
|
||||
example help config show
|
||||
example config --help
|
||||
```
|
||||
|
||||
`help [COMMAND...]` resolves an exact registered path. A command group without
|
||||
an execution handler displays its help when invoked by itself. A runnable
|
||||
command with children runs its handler when invoked without help; add `--help`
|
||||
to inspect that command and its children.
|
||||
|
||||
Help uses registered descriptions, command summaries, local flags, defaults,
|
||||
required and repeatable flag metadata, and operand names and counts. It does not
|
||||
construct the selected command's input or invoke its handler. Supplied flag and
|
||||
operand values are still parsed so malformed values and unknown flags remain
|
||||
usage errors. Missing execution-required values and input-combination checks
|
||||
are skipped for help.
|
||||
|
||||
## Version
|
||||
|
||||
`version` reports the application identity by default:
|
||||
|
||||
```text
|
||||
example version
|
||||
example version --scope commandkit
|
||||
example version --format yaml
|
||||
```
|
||||
|
||||
The supported flags are:
|
||||
|
||||
| Flag | Values | Default | Meaning |
|
||||
| --- | --- | --- | --- |
|
||||
| `--scope` | `app`, `commandkit` | `app` | Select the caller's application identity or the embedded CommandKit module identity. |
|
||||
| `--format` | `text`, `yaml` | `text` | Select the output format. |
|
||||
|
||||
Text output is `NAME VERSION`, followed by ` (REVISION)` when the selected
|
||||
identity has a revision. An empty application version is displayed as `dev`;
|
||||
the revision remains empty when omitted.
|
||||
|
||||
CommandKit identity uses the version of its module in build information. A
|
||||
versioned module replacement supplies the effective version. A local or
|
||||
versionless replacement, an untagged module, or missing build information
|
||||
displays `dev`. The CommandKit identity name is `CommandKit`; dependency build
|
||||
metadata does not supply a revision.
|
||||
|
||||
YAML output uses these explicit fields, including an empty revision:
|
||||
|
||||
```yaml
|
||||
name: ExampleApp
|
||||
version: dev
|
||||
revision: ""
|
||||
```
|
||||
|
||||
## Registered command syntax
|
||||
|
||||
Options are parsed after the complete command path and may be interspersed with
|
||||
declared operands. Flags are local to the selected command. Use `--` to end
|
||||
option parsing; all later tokens are operands.
|
||||
|
||||
Value flags accept `--name value` and `--name=value`. Boolean flags accept
|
||||
presence as true and explicit values such as `--enabled=false`. A singleton
|
||||
flag accepts repeated occurrences; the last successfully parsed occurrence
|
||||
supplies its value. Every supplied occurrence is converted, so an earlier
|
||||
malformed value remains an error. Repeatable flags preserve occurrence order,
|
||||
with each occurrence treated as one value, including strings containing commas.
|
||||
|
||||
Typed inputs keep supplied state separate from defaults. An explicit empty,
|
||||
false, or zero value is supplied. Help and version are available without
|
||||
constructing application command inputs.
|
||||
|
||||
## Outcome status
|
||||
|
||||
CommandKit usage failures use status `2`; operational failures use status `1`.
|
||||
Successful operations use status `0`. Application handlers may return a domain
|
||||
classification and status of their choice, which `Execute` preserves. The caller
|
||||
chooses how to map an outcome to process exit.
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
CommandKit currently contains adopted repository policies, accepted architectural
|
||||
decisions, implementation plans, identity and outcome primitives, typed command
|
||||
declarations, an instance-owned registry, and a Cobra-backed routing and parsing
|
||||
adapter, plus public `App.Execute` coordination for custom commands. Generated
|
||||
help/version rendering and standard command families remain pending. The
|
||||
declarations, an instance-owned registry, a Cobra-backed routing and parsing
|
||||
adapter, public `App.Execute` coordination, and generated help/version commands.
|
||||
Standard command families remain pending. The
|
||||
[README](../README.md) provides project orientation; the
|
||||
[documentation policy](policy/documentation.md#canonical-ownership) assigns
|
||||
canonical documentation owners.
|
||||
@@ -44,6 +44,7 @@ canonical documentation owners.
|
||||
|
||||
| Task | Read |
|
||||
| --- | --- |
|
||||
| Implemented CLI behavior | [CLI reference](cli.md) |
|
||||
| Standard command vocabulary, reports, or remaining operator-contract proposals | [CLI plan](roadmap/01-cli-plan.md) |
|
||||
| Dispatcher, registration, or typed input design | [Dispatcher roadmap](roadmap/02-dispatch.md) and [ADR 0001](adr/0001-command-dispatch-and-inputs.md) |
|
||||
| Backend integration | [Backend roadmap](roadmap/03-backend.md) and [ADR 0002](adr/0002-cobra-backend.md) |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Initial CommandKit implementation plan
|
||||
|
||||
Status: implementation underway; Stages 1-5 complete and Stages 6-14 pending.
|
||||
Status: implementation underway; Stages 1-6 complete and Stages 7-14 pending.
|
||||
|
||||
Date: 2026-10-07.
|
||||
|
||||
@@ -401,7 +401,7 @@ will set `ReportIncomplete` when introduced with the standard reports.
|
||||
|
||||
## Stage 6: complete help and version
|
||||
|
||||
**Status:** pending. **Prerequisite:** Stage 5.
|
||||
**Status:** complete. **Prerequisite:** Stage 5.
|
||||
|
||||
1. Complete automatically installed `help` and `version`. Root bare invocation,
|
||||
`help [COMMAND…]`, root/selected `--help`/`-h`, and non-runnable groups render
|
||||
@@ -439,6 +439,13 @@ help stream failure is operational; default version contains only app identity;
|
||||
controlled build info covers tagged/development/replacement component selection.
|
||||
Create/update the substantive help/version portion of `docs/cli.md` now.
|
||||
|
||||
**Completion evidence:** external tests cover root, group, runnable-parent, and
|
||||
exact-path help; help without required inputs; version text/YAML and invalid
|
||||
selectors; and checked report-write failures. Pure build-info tests cover main,
|
||||
dependency, tagged replacement, local replacement, development, and missing
|
||||
module cases. `go test ./...` passes; README and CLI reference describe the
|
||||
implemented boundary.
|
||||
|
||||
## Stage 7: implement configuration suites, scopes, and selector preflight
|
||||
|
||||
**Status:** pending. **Prerequisite:** Stage 6.
|
||||
|
||||
Reference in New Issue
Block a user