Skip to content

Command surface: help, version and argument errors - #40

Merged
JacobStephens2 merged 2 commits into
mainfrom
issue-31
Sep 25, 2026
Merged

JacobStephens2 merged 2 commits into
mainfrom
issue-31

Conversation

@JacobStephens2

Copy link
Copy Markdown
Owner

Summary

main now works out which command it was given before any Run starts:

main
  match first argument
    help | --help | -h           -> print HELP to stdout, exit 0
    version | --version | -V     -> print "thirdshift <version>" to stdout, exit 0
    update                       -> "update is not yet available" on stderr, exit 1
    anything else                -> IssueUrl::parse
                                      error -> error line + HELP on stderr, exit 2
    (none)                       -> "missing Issue URL" + HELP on stderr, exit 2
  run::run(&issue)               # unchanged

The help text replaces the old one-line usage: thirdshift <Issue URL>. It keeps that string as its first form line, so the existing pre-flight tests pass unchanged. The flag aliases don't appear in the help text or the README.

Seams tested: the built binary run as a subprocess (tests/command_surface.rs), asserting only on stdout, stderr and the exit code.

Evidence

  • Before: thirdshift help → thirdshift: not a GitHub issue URL: help / usage: thirdshift <Issue URL> on stderr, exit 2. thirdshift version behaves the same way.
    After:
    $ thirdshift help; echo "exit $?"
    thirdshift turns a GitHub issue into a ready-for-review pull request, unattended.
    
    usage: thirdshift <Issue URL>   Run the factory on the issue, from the clone on the Base branch
           thirdshift update        Update thirdshift to the latest release
           thirdshift version       Print thirdshift's version
           thirdshift help          Print this help
    exit 0
    $ thirdshift -V
    thirdshift 0.1.0
    $ thirdshift frobnicate >/dev/null; echo "exit $?"
    thirdshift: not a GitHub issue URL: frobnicate
    
    thirdshift turns a GitHub issue ...   (help text as above)
    exit 2
    
  • tests/command_surface.rs: 7 new tests pass. They cover help and its aliases, the aliases being absent from the help text, version and its aliases, the three argument errors, and update not being available yet.
  • Full cargo test: everything passes except ci::waits_for_github_to_work_out_whether_the_pr_is_mergeable. That test also fails 4 times out of 4 on main on this machine, so this change didn't cause it. It depends on timing and fails under load.

Merge Danger

Door: two-way

Blast Radius: CLI

Two things change for scripts that call thirdshift: help and version now exit 0 instead of 2, and argument errors print more text to stderr. The Run path is unchanged.

Unaddressed findings

Standards

  • Divergent Change: pull argument parsing out of main into a pure Command parse function. Skipped. The issue asks for tests that run the binary as a subprocess, and a five-arm match doesn't yet need its own module.
  • Speculative Generality: the update stub is advertised but always fails. Skipped. The issue asks for update in the help text and allows the "not yet available" exit 1 until a later ticket.
  • Duplicated Code: the new argument-error tests overlap the tests/preflight.rs usage tests, which still assert on usage: thirdshift <Issue URL>. Skipped. The issue requires the existing Run tests to pass unchanged, so I didn't edit them. The help text keeps that line on purpose.

Spec

  • Scope creep: the help text opens with a tagline and a usage: prefix. Skipped. The usage: prefix keeps the existing tests passing unchanged, and one tagline line is harmless.
  • The help text describes update although it isn't implemented. Skipped. The issue explicitly allows this.
  • An unknown word gets "not a GitHub issue URL" rather than "unknown command". Skipped. The existing pre-flight test expects not a GitHub issue URL: 7 for the bare word 7, and it must pass unchanged. One message for every rejected argument is also simpler.
  • The usage: thirdshift <Issue URL> pre-flight assertions pass only because the help contains that substring. Skipped. This is deliberate, for the "pass unchanged" criterion.
  • Extra arguments after the first are ignored. Skipped. This is how the Run already behaved, and the issue says it should behave "exactly as before".

Closes #31

🤖 Generated with Claude Code

JacobStephens2 and others added 2 commits September 25, 2026 15:25
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Command surface: help, version and argument errors

1 participant