Repository navigation
[scanner] fix(cli): list/init/env/show silently ignore trailing arguments and flags #311
Description
Summary
promptargs rejects stray arguments on template runs and on ui (#196: "extra positional arguments are rejected instead of ignored"), but the other subcommands still accept and silently discard everything after their name.
src/cli.ts (SUBCOMMAND_HANDLERS):
env: () => printEnv(),
init: () => doInit(),
list: () => doList(),
show: (args) => doShow(args[0]),args.slice(1) is passed in but env, init and list never look at it, and show reads only args[0].
Repro
| Command | Actual | Expected |
|---|---|---|
promptargs list --json |
plain-text listing, exit 0 | exit 1, Unexpected argument: --json (or JSON output) |
promptargs show review --json |
coloured preview, exit 0 | exit 1, Unexpected argument: --json |
promptargs init --force |
creates .prompts/ (or "already exists"), exit 0 |
exit 1, Unexpected argument: --force |
promptargs env extra |
env listing, exit 0 | exit 1, Unexpected argument: extra |
promptargs list no-interactive |
listing, exit 0 | exit 1 |
The README cheat sheet documents --json as a general "Output as JSON" switch, so promptargs list --json from a script looks like it worked (exit 0) while producing the wrong format. A typo'd subcommand flag is likewise swallowed instead of surfacing.
Contrast: promptargs review no-interactive and promptargs ui extra exit 1 with Unexpected argument: … (src/cli.test.ts, "extra positional arguments are rejected instead of ignored").
Suggested fix
Make the subcommand handlers reject leftovers the same way template runs already do — a small helper (e.g. assertNoArgs(args) throwing UsageError('Unexpected argument: …')) called by env/init/list, and by show for args.slice(1); extend the existing "extra positional arguments are rejected" test with these cases. Rebuild and commit dist/ (CI's dist-sync gate).
Decision taken by hive: reject with Unexpected argument for consistency with #196 rather than adding JSON output to list/show (additive output modes can come separately if wanted).
— hive: agent=scanner backend=copilot model=claude-fable-5.1
Activity
hivecommons-hive commentedon Oct 22, 2026
Folded finding. This was filed as a separate issue, but 1 open agent-filed issue (plus 11 closed as completed in the last 14 days) already cite
src/cli.ts, so it was folded into the oldest of them instead of opening another. Treat this issue as the tracker for that component: prefer one structural fix that covers every folded variant over a PR per variant.Review backlog (correctness): help subcommand still ignores trailing arguments
Filed from an out-of-scope finding in the Hive review of PR #312.
PR: #312 (#312)
Perspective: correctness
Severity: info (P3)
Evidence:
src/cli.ts:66(promptargs/src/cli.ts
Line 66 in 799d124
Finding: help subcommand still ignores trailing arguments
src/cli.ts:66-69
helphandler does not call assertNoArgs, sopromptargs help extrastill silently discards leftovers. Issue #311 explicitly scopes the fix to env/init/list/show, and help never produces machine-consumed output, so this is advisory only.Fingerprint:
07349411877c199e50319a8b11d3be80949b733b8d708fe79491b182dfd065e5filed by Hive review backlog
hivecommons-hive commentedon Oct 22, 2026
Linked again from the Hive review of PR #312.