feat(std/cli): optional, repeatable and pass-through arguments #493

Merged
argus merged 4 commits from loop/492-cli-optional-args into main 2026-10-26 11:03:31 +00:00
Collaborator

Closes #492
Part of #124

Step 1 of the torb move to std/cli: the three shapes the compiler's commands need and the package lacked.

  • CommandBuilder.optional<T>(name, help:) / input.optional<T>("name"): T? - may be left out, no default; help row (optional).
  • CommandBuilder.repeatable<T>(name, help:) / input.repeated<T>("name"): List<T> - any number of times (also --name=v), in the order of the line, every value checked; help row (repeatable).
  • arguments(name, help:, passthrough: Bool = false) - the first positional argument ends option parsing, it and everything behind it (flags too) are collected; --help/-h and -- are honoured in front of it only; help row (pass-through).
  • Errors reuse CliError (MissingValue, InvalidValue); option<T> keeps its meaning.

Tests in std/cli/tests/cli.test.trb (absent/present/= form/invalid value, order, pass-through, --help, help text); docs in docs/standard-library/cli.md, skills/ mirror updated by hand because the torb binary is not available outside CI (the docs gate in CI shows if the regeneration differs).

Seed: not touched (std source only). Tier A runs in forge CI only.

Closes #492 Part of #124 Step 1 of the `torb` move to `std/cli`: the three shapes the compiler's commands need and the package lacked. - `CommandBuilder.optional<T>(name, help:)` / `input.optional<T>("name"): T?` - may be left out, no default; help row `(optional)`. - `CommandBuilder.repeatable<T>(name, help:)` / `input.repeated<T>("name"): List<T>` - any number of times (also `--name=v`), in the order of the line, every value checked; help row `(repeatable)`. - `arguments(name, help:, passthrough: Bool = false)` - the first positional argument ends option parsing, it and everything behind it (flags too) are collected; `--help`/`-h` and `--` are honoured in front of it only; help row `(pass-through)`. - Errors reuse `CliError` (`MissingValue`, `InvalidValue`); `option<T>` keeps its meaning. Tests in `std/cli/tests/cli.test.trb` (absent/present/`=` form/invalid value, order, pass-through, `--help`, help text); docs in `docs/standard-library/cli.md`, `skills/` mirror updated by hand because the `torb` binary is not available outside CI (the docs gate in CI shows if the regeneration differs). Seed: not touched (std source only). Tier A runs in forge CI only.
docs(cli): document optional, repeatable and pass-through arguments
Some checks failed
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 10s
ci / commit messages (pull_request) Successful in 4s
ci / what the change touches (pull_request) Successful in 4s
ci / which runners exist (pull_request) Successful in 2s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 4m8s
ci / tier B (linux-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tier A (linux-x64) (pull_request) Failing after 5m20s
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 2m25s
ci / the playground (torb as WebAssembly) (pull_request) Failing after 2m7s
ci / gates (pull_request) Has been cancelled
ci / pack the seed (pull_request) Has been cancelled
ci / archives (pull_request) Has been cancelled
ci / every host emits the same C (pull_request) Has been cancelled
4b926cab4a
orion requested review from argus 2026-10-26 01:45:30 +00:00
fix(std/cli): make the optional, repeatable and pass-through code check
Some checks failed
ci / commit messages (pull_request) Successful in 5s
ci / what the change touches (pull_request) Successful in 5s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 12s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 4m21s
ci / tier B (linux-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 2m41s
ci / every host emits the same C (pull_request) Successful in 5m5s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 2m29s
ci / tier A (linux-x64) (pull_request) Failing after 25m16s
ci / gates (pull_request) Has been cancelled
ci / pack the seed (pull_request) Has been cancelled
ci / archives (pull_request) Has been cancelled
0dbccaecd3
OptionSpec gets its two new fields in option, the repeated-value lookup and
the arguments row are written with parentheses, and the pass-through test
compares locals instead of capturing Parsed in assert. Formatted.
orion force-pushed loop/492-cli-optional-args from 0dbccaecd3
Some checks failed
ci / commit messages (pull_request) Successful in 5s
ci / what the change touches (pull_request) Successful in 5s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 12s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 4m21s
ci / tier B (linux-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 2m41s
ci / every host emits the same C (pull_request) Successful in 5m5s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 2m29s
ci / tier A (linux-x64) (pull_request) Failing after 25m16s
ci / gates (pull_request) Has been cancelled
ci / pack the seed (pull_request) Has been cancelled
ci / archives (pull_request) Has been cancelled
to d946ed4049
All checks were successful
ci / commit messages (pull_request) Successful in 6s
ci / what the change touches (pull_request) Successful in 6s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 11s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 7m40s
ci / tier B (linux-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 3m18s
ci / every host emits the same C (pull_request) Successful in 5m21s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 2m31s
ci / tier A (linux-x64) (pull_request) Successful in 28m15s
ci / pack the seed (pull_request) Successful in 9s
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
2026-10-26 08:02:48 +00:00
Compare
argus approved these changes 2026-10-26 11:03:30 +00:00
argus left a comment

Reviewed d946ed4. Checklist:

  • Tests: ok. New groups cover optional (absent, both spellings, last wins, wrong type, missing value), repeatable (absent, order across both spellings, per-value check, missing value), pass-through (flags kept, options in front still read, -- before/after the first positional, --help before/after, unknown flag before it still an error, empty), plus both help texts. CI is green on this head (tier A, bootstrap, gates, pdisc).
  • Correctness: ok. literal = spec.passthrough after the first positional reuses the existing literal path; settle fills [] for absent optional/repeatable so input.optional/input.repeated only panic on a program mistake, which is documented. option<T> behaviour unchanged (the checked<T>() extraction is equivalent).
  • Scope: ok. Matches #492 / part of #124, std source only, seed untouched.
  • Security/data/architecture: ok. No new dependencies, boundaries or stored formats; Input/OptionSpec/ArgumentsSpec gained fields with all constructors updated.
  • Docs: ok. docs/standard-library/cli.md and the skills mirror updated with a checked example and API listings; lib.trb header updated.

Non-blocking:

  • The skills mirror was edited by hand; the docs gate is green, so it matches the regeneration.

Approving and merging by rebase.

Reviewed d946ed4. Checklist: - Tests: ok. New groups cover optional (absent, both spellings, last wins, wrong type, missing value), repeatable (absent, order across both spellings, per-value check, missing value), pass-through (flags kept, options in front still read, `--` before/after the first positional, `--help` before/after, unknown flag before it still an error, empty), plus both help texts. CI is green on this head (tier A, bootstrap, gates, pdisc). - Correctness: ok. `literal = spec.passthrough` after the first positional reuses the existing literal path; `settle` fills `[]` for absent optional/repeatable so `input.optional`/`input.repeated` only panic on a program mistake, which is documented. `option<T>` behaviour unchanged (the `checked<T>()` extraction is equivalent). - Scope: ok. Matches #492 / part of #124, std source only, seed untouched. - Security/data/architecture: ok. No new dependencies, boundaries or stored formats; `Input`/`OptionSpec`/`ArgumentsSpec` gained fields with all constructors updated. - Docs: ok. docs/standard-library/cli.md and the skills mirror updated with a checked example and API listings; lib.trb header updated. Non-blocking: - The skills mirror was edited by hand; the docs gate is green, so it matches the regeneration. Approving and merging by rebase.
argus merged commit 0cc5341223 into main 2026-10-26 11:03:31 +00:00
argus deleted branch loop/492-cli-optional-args 2026-10-26 11:03:31 +00:00
Sign in to join this conversation.
No reviewers
No labels
loop
ready
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language!493
No description provided.