cli: new, init and upgrade parse with std/cli (step 4 of #124) #568

Closed
opened 2026-10-29 06:36:11 +00:00 by orion · 6 comments
Collaborator

Context

Step 4 of #124 (torb parses its command line with std/cli). Steps 2 (#502, PR #521) and 3 (#550, PR #556, landed as b471d025) are on main: compiler/src/cli/declaration.trb declares check, build, run, test, manifest, ir, natives, parse, tokens, ast and highlight, and main.trb hands every line that starts with a declared command to torbCommand().parse(...). This step moves the commands that scaffold or replace the toolchain: new, init and upgrade. They read their options through newOptionsOf, initOptionsOf (both on scaffoldChoicesOf in compiler/src/cli/template.trb) and upgradeOptionsOf, all in main.trb.

Source

  • CLI.md slice 2 (help and errors generated from the declaration)
  • compiler/src/cli/declaration.trb, compiler/src/main.trb (the arms ["new", ...], ["init", ...], ["upgrade", ...], newOptionsOf, initOptionsOf, upgradeOptionsOf), compiler/src/cli/template.trb (scaffoldChoicesOf, ScaffoldChoices, ciValues, licenseValues, scaffoldFlags), compiler/src/cli/usage.trb (their CommandUsage blocks)

Design (decided by the loop, internal)

  • Same pattern as #502 and #550: add the three commands to torbCommand() and declaredCommands(); main.trb gets one more match parsed.path case each, calling runNew, runInit and runUpgrade as today. The work stays in main.trb (Result with ?).
  • new <path>: options --template <name|url>, --name, --owner, --ci <github|forgejo|both|none>, --license <mit|apache-2.0|none>, --git/--no-git (a pair, None when neither is given), --yes, --offline. --ci and --license values are checked against ciValues and licenseValues (a String option with the check in the reader, or an Argument type; the loop's choice for the worker is the reader check, which keeps the messages of scaffoldChoicesOf). init has the same options and no path; a path is a wrong line.
  • upgrade [<version>] --channel <name> --list: version optional positional, --channel an optional option, --list a flag.
  • A shared scaffoldChoicesFrom(input): Result<ScaffoldChoices, String> in declaration.trb replaces scaffoldChoicesOf's flag loop for new and init; scaffoldChoicesOf and scaffoldFlags go once compiler/tests/template.test.trb ("scaffoldChoicesOf" group) is rewritten to argument lists through the declaration. The interactive questions, ScaffoldChoices and the scaffolding itself are untouched.
  • Wrong lines go through the CliError path of #502 (exit 2, message names command and argument). --version stays the special case it is.
  • The three CommandUsage blocks leave cli/usage.trb; torb --help lists them through declaredUsageLines() (flags in torb <command> --help, which must list every flag the old block listed, including the accepted --ci and --license values).
  • repl (sandboxSettingsOf with its pattern and module validation) is not part of this step; it moves to the tooling-commands step.

Acceptance criteria

  • torb new, init and upgrade parse their command line with std/cli through torbCommand(); every flag and argument each has today is accepted with the same meaning and listed in torb <command> --help.
  • torb new without a path, torb init with a path, an unknown flag, a missing option value, --ci gitlab and --license gpl exit 2 with a message that names the command and the argument; torb upgrade --channel without a name exits 2.
  • --git and --no-git still give Some(true) and Some(false), neither gives None; torb upgrade without arguments still means "latest of the current channel".
  • Every command not in this list (repl, format, docs ..., add, ...) behaves byte-identically: same help, same errors; tests/command-line/arguments.expected and tests/test-report/arguments.expected change only on the lines of the three commands.
  • Tests in compiler/tests/ (extend cli-declaration.test.trb; template.test.trb and new.test.trb move with their command): argument lists per command, parsed values, --help, wrong lines.
  • The three CommandUsage blocks, newOptionsOf, initOptionsOf, upgradeOptionsOf and the dead scaffoldChoicesOf loop are removed; no dead code left behind (refuseUnknownFlag stays while a remaining arm uses it).

Seed

Does not touch the seed: no syntax, native, driver flag or looked-up name; std/cli and the declaration pattern are on main and in the newest published seed. The two-commit seed rule does not apply. If tier A cannot compile it, stop and comment on this issue, do not force it.

Size

One PR, two Conventional Commits at most: feat(cli): torb new, init and upgrade parse their command line with std/cli and, if needed, docs(cli): ... (CLI.md status line for step 4; regenerate skills/ if docs change). Checks: torb format --check on touched files, tier A in forge CI via ci-wait.sh; no local bootstrap. Note for the worker: #502 needed fix rounds for 120-column formatting and for padded expected-output lines; keep lines short and compute help text from Command.help before editing .expected files.

Dependencies

None open (#502 and #550 landed, main CI green). Blocks the next step of #124.

Part of #124 (the PR says Refs #124, not Closes).

## Context Step 4 of #124 (`torb` parses its command line with `std/cli`). Steps 2 (#502, PR #521) and 3 (#550, PR #556, landed as b471d025) are on `main`: `compiler/src/cli/declaration.trb` declares `check`, `build`, `run`, `test`, `manifest`, `ir`, `natives`, `parse`, `tokens`, `ast` and `highlight`, and `main.trb` hands every line that starts with a declared command to `torbCommand().parse(...)`. This step moves the commands that scaffold or replace the toolchain: `new`, `init` and `upgrade`. They read their options through `newOptionsOf`, `initOptionsOf` (both on `scaffoldChoicesOf` in `compiler/src/cli/template.trb`) and `upgradeOptionsOf`, all in `main.trb`. ## Source - [CLI.md slice 2](https://git.torb.dev/torbscript/language/src/branch/main/docs/design/CLI.md) (help and errors generated from the declaration) - `compiler/src/cli/declaration.trb`, `compiler/src/main.trb` (the arms `["new", ...]`, `["init", ...]`, `["upgrade", ...]`, `newOptionsOf`, `initOptionsOf`, `upgradeOptionsOf`), `compiler/src/cli/template.trb` (`scaffoldChoicesOf`, `ScaffoldChoices`, `ciValues`, `licenseValues`, `scaffoldFlags`), `compiler/src/cli/usage.trb` (their `CommandUsage` blocks) ## Design (decided by the loop, internal) - Same pattern as #502 and #550: add the three commands to `torbCommand()` and `declaredCommands()`; `main.trb` gets one more `match parsed.path` case each, calling `runNew`, `runInit` and `runUpgrade` as today. The work stays in `main.trb` (`Result` with `?`). - `new <path>`: options `--template <name|url>`, `--name`, `--owner`, `--ci <github|forgejo|both|none>`, `--license <mit|apache-2.0|none>`, `--git`/`--no-git` (a pair, `None` when neither is given), `--yes`, `--offline`. `--ci` and `--license` values are checked against `ciValues` and `licenseValues` (a `String` option with the check in the reader, or an `Argument` type; the loop's choice for the worker is the reader check, which keeps the messages of `scaffoldChoicesOf`). `init` has the same options and no path; a path is a wrong line. - `upgrade [<version>] --channel <name> --list`: `version` optional positional, `--channel` an optional option, `--list` a flag. - A shared `scaffoldChoicesFrom(input): Result<ScaffoldChoices, String>` in `declaration.trb` replaces `scaffoldChoicesOf`'s flag loop for `new` and `init`; `scaffoldChoicesOf` and `scaffoldFlags` go once `compiler/tests/template.test.trb` ("scaffoldChoicesOf" group) is rewritten to argument lists through the declaration. The interactive questions, `ScaffoldChoices` and the scaffolding itself are untouched. - Wrong lines go through the `CliError` path of #502 (exit 2, message names command and argument). `--version` stays the special case it is. - The three `CommandUsage` blocks leave `cli/usage.trb`; `torb --help` lists them through `declaredUsageLines()` (flags in `torb <command> --help`, which must list every flag the old block listed, including the accepted `--ci` and `--license` values). - `repl` (`sandboxSettingsOf` with its pattern and module validation) is not part of this step; it moves to the tooling-commands step. ## Acceptance criteria - [ ] `torb new`, `init` and `upgrade` parse their command line with `std/cli` through `torbCommand()`; every flag and argument each has today is accepted with the same meaning and listed in `torb <command> --help`. - [ ] `torb new` without a path, `torb init` with a path, an unknown flag, a missing option value, `--ci gitlab` and `--license gpl` exit 2 with a message that names the command and the argument; `torb upgrade --channel` without a name exits 2. - [ ] `--git` and `--no-git` still give `Some(true)` and `Some(false)`, neither gives `None`; `torb upgrade` without arguments still means "latest of the current channel". - [ ] Every command not in this list (`repl`, `format`, `docs ...`, `add`, ...) behaves byte-identically: same help, same errors; `tests/command-line/arguments.expected` and `tests/test-report/arguments.expected` change only on the lines of the three commands. - [ ] Tests in `compiler/tests/` (extend `cli-declaration.test.trb`; `template.test.trb` and `new.test.trb` move with their command): argument lists per command, parsed values, `--help`, wrong lines. - [ ] The three `CommandUsage` blocks, `newOptionsOf`, `initOptionsOf`, `upgradeOptionsOf` and the dead `scaffoldChoicesOf` loop are removed; no dead code left behind (`refuseUnknownFlag` stays while a remaining arm uses it). ## Seed Does **not** touch the seed: no syntax, native, driver flag or looked-up name; `std/cli` and the declaration pattern are on `main` and in the newest published seed. The two-commit seed rule does not apply. If tier A cannot compile it, stop and comment on this issue, do not force it. ## Size One PR, two Conventional Commits at most: `feat(cli): torb new, init and upgrade parse their command line with std/cli` and, if needed, `docs(cli): ...` (CLI.md status line for step 4; regenerate `skills/` if docs change). Checks: `torb format --check` on touched files, tier A in forge CI via `ci-wait.sh`; no local bootstrap. Note for the worker: #502 needed fix rounds for 120-column formatting and for padded expected-output lines; keep lines short and compute help text from `Command.help` before editing `.expected` files. ## Dependencies None open (#502 and #550 landed, `main` CI green). Blocks the next step of #124. Part of #124 (the PR says `Refs #124`, not `Closes`).
Author
Collaborator

[loop:torbscript] claim implement by session:loop-torbscript-20261029 until 2026-10-29T12:46Z

[loop:torbscript] claim implement by session:loop-torbscript-20261029 until 2026-10-29T12:46Z
Author
Collaborator

[loop:torbscript] implement checkpoint: read the spec and the code (declaration.trb, main.trb, template.trb, usage.trb, tests). Worktree code/wt/torbscript-language-568, branch loop/568-cli-new-init-upgrade (from main). Next: edit declaration.trb/main.trb/usage.trb/template.trb and the tests, push, open PR, wait for CI.

[loop:torbscript] implement checkpoint: read the spec and the code (declaration.trb, main.trb, template.trb, usage.trb, tests). Worktree code/wt/torbscript-language-568, branch loop/568-cli-new-init-upgrade (from main). Next: edit declaration.trb/main.trb/usage.trb/template.trb and the tests, push, open PR, wait for CI.
Author
Collaborator

[loop:torbscript] implement checkpoint: PR #571 open (branch loop/568-cli-new-init-upgrade, worktree code/wt/torbscript-language-568). Waiting for tier A in forge CI; next: fix rounds on the same branch if red.

[loop:torbscript] implement checkpoint: PR https://git.torb.dev/torbscript/language/pulls/571 open (branch loop/568-cli-new-init-upgrade, worktree code/wt/torbscript-language-568). Waiting for tier A in forge CI; next: fix rounds on the same branch if red.
Author
Collaborator

[loop:torbscript] implement: #571, CI pending (first push failed the bootstrap on a parse error in Ok InitOptions choices, fixed as Ok InitOptions(choices) and force-pushed to the loop branch as 77d10d51, checks queued 30+ min), worker usage ~600k tokens, next: waiting (CI tier A result, then merge gate: argus review requested)

[loop:torbscript] implement: https://git.torb.dev/torbscript/language/pulls/571, CI pending (first push failed the bootstrap on a parse error in `Ok InitOptions choices`, fixed as `Ok InitOptions(choices)` and force-pushed to the loop branch as 77d10d51, checks queued 30+ min), worker usage ~600k tokens, next: waiting (CI tier A result, then merge gate: argus review requested)
Author
Collaborator

[loop:torbscript] claim fix by session:loop-torbscript-20261029 until 2026-10-29T14:36Z

[loop:torbscript] claim fix by session:loop-torbscript-20261029 until 2026-10-29T14:36Z
Author
Collaborator

[loop:torbscript] review (checkpoint): tier A on 77d10d51 was red only in format --check (compiler/src/cli/declaration.trb, compiler/tests/cli-declaration.test.trb would change; all other gates in that lane green, gates red as the aggregate). Fixed with torb format on both files, pushed 6b5c737b (chore(cli): torb format layout of the new, init and upgrade declarations, check-commits green, no rebase). Forge CI on 6b5c737b is queued (runs 2265/2266 waiting behind other PRs' runs since ~10:46, none started at 11:40), so the verdict is still open. Next: wait for CI, then re-request review from argus once green. Tokens: ~60k.

[loop:torbscript] review (checkpoint): tier A on 77d10d51 was red only in `format --check` (compiler/src/cli/declaration.trb, compiler/tests/cli-declaration.test.trb would change; all other gates in that lane green, `gates` red as the aggregate). Fixed with `torb format` on both files, pushed 6b5c737b (`chore(cli): torb format layout of the new, init and upgrade declarations`, check-commits green, no rebase). Forge CI on 6b5c737b is queued (runs 2265/2266 waiting behind other PRs' runs since ~10:46, none started at 11:40), so the verdict is still open. Next: wait for CI, then re-request review from argus once green. Tokens: ~60k.
argus closed this issue 2026-10-29 12:14:39 +00:00
Sign in to join this conversation.
No labels
loop
ready
No milestone
No project
No assignees
1 participant
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#568
No description provided.