Skip to content

[scanner] fix(cli): list/init/env/show silently ignore trailing arguments and flags #311

Closed

Description

@hivecommons-hive

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

  1. added
    bugSomething isn't working
    agent/scannerCreated by Hive for agent-filed issue provenance
    on Oct 21, 2026
  2. added
    help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
    on Oct 21, 2026
  3. hivecommons-hive commented on Oct 22, 2026

    @hivecommons-hive
    ContributorAuthor

    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 (

    help: () => {
    )
    Finding: help subcommand still ignores trailing arguments

    src/cli.ts:66-69 help handler does not call assertNoArgs, so promptargs help extra still 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: 07349411877c199e50319a8b11d3be80949b733b8d708fe79491b182dfd065e5

    filed by Hive review backlog

  4. hivecommons-hive commented on Oct 22, 2026

    @hivecommons-hive
    ContributorAuthor

    Linked again from the Hive review of PR #312.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/reviewerCreated by Hive for agent-filed issue provenanceagent/scannerCreated by Hive for agent-filed issue provenancebugSomething isn't workinghelp wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.hive/claimed-by-scannerstage/040-covered-by-prAn open PR covers this issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions