cli: std/cli (CLI slice 1) #123
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Commands, flags, options, positional arguments, help and errors declared once.
Source
Acceptance criteria
Dependencies
None known.
Moved from the planning lists of the docs; the design record stays the specification.
torbparses its command line withstd/cli(CLI slice 2) #124[loop:torbscript] intake: in scope (author orion, label loop), source CLI.md slice 1, not a duplicate. No dependencies. next: waiting (refine queued, ready buffer full) until 2026-10-10T04:00:00Z
torbparses its command line withstd/cli(CLI slice 2) #124[loop:torbscript] claim refine by session:loop-torbscript-20261023 until 2026-10-23T13:38Z
[loop:torbscript] decided by the loop: typed options in slice 1,
decode<T>later. Why: CLI.md section 2 item 1 is a question of taste "decided with the first probe", i.e. an internal design choice (contract: loop decides, no owner question).option<Int>("jobs", default: 4)read back asinput.option<Int>("jobs")needs only string-to-value conversion in a pure package; theDecode-based variant needs aDecoderover the argument map andDescribewiring into help, which is larger and best judged once slice 2 (torbitself, #124) shows real option structs. Shell completion (item 2) stays slice 3 (#125). Slice 1 therefore fits one PR; the decoded form becomes its own issue only if slice 2 wants it.[loop:torbscript] refine: ready.
Goal. New package
std/cli(pure exceptrun, which only reads the argument list it is given): a program declares commands (nested), flags, options and positional arguments once, with a receiver-closure builder as in CLI.md section 1; help text and errors are generated from the declaration.Design point. docs/design/CLI.md sections 1, 2 (item 1 decided above) and 3 (slice 1); ROADMAP
std/clirow (#123).Seed. Does not touch the seed: new std package, no syntax change, no new native, no driver flag, no std name the compiler looks up by string. (The compiler importing it is slice 2, #124, and needs the seed refresh there, Torben's.)
Acceptance criteria.
std/cliexists (project.trb,src/,tests/) and is importable asstd/cli; building a tree withcommand "name" { description ...; command ...; flag ...; option<T>(...); arguments ...; run { input => ... } }as in CLI.md section 1 compiles.flag("x")reads asinput.flag("x")(--x, absent = false);option<T>("jobs", default: 4)reads asinput.option<T>("jobs")for at leastInt,Float64,BoolandString; both--jobs 8and--jobs=8work; a missing option without default and an unparsable value are errors.arguments("paths")collects the rest as a list;--ends option parsing.run.--help, andhelplisting) is generated from the declaration: description, subcommands, flags, options with defaults, arguments.List<String>) to the package and assert the parsed values, the help text and the exact error messages (happy path and each error case above).docs/standard-library/cli.md(andskills/regenerated if the docs gate asks), CLI.md status and section 2 item 1 updated to the decision.Size. One PR, two Conventional Commits:
feat(std/cli): commands, flags, options and arguments(package + tests) anddocs(cli): std/cli reference and CLI.md decision. Gates: tier A in forge CI (the loop does not run bootstrap locally).Out of scope.
torbmigration (#124), shell completion (#125), aDecode-baseddecode<T>(), environment-variable fallbacks.Tokens used by this refine worker: not exposed to the worker (a small read-only pass: issue, CLI.md, ROADMAP rows, std layout).
next: implement
[loop:torbscript] claim implement by session:loop-torbscript-20261023 until 2026-10-23T17:50Z
torbparses its command line withstd/cli(CLI slice 2) #124