Skip to content

Stop treating command-line options as GitHub user names - #59

Merged
dmccoystephenson merged 1 commit into
mainfrom
feature/cli-option-arguments
Nov 5, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
feature/cli-option-arguments

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

  • -h and --help are now handled as options: the usage message is printed, status 0 is returned, and GitHub is not contacted. Previously --help was looked up as a user, and status 1 was returned when the lookup failed.
  • Any other argument starting with a hyphen is now reported as Error: Unknown option: <arg>, with the usage message written to standard error. Nothing is backed up, and the new status 2 is returned, so that a command-line mistake can be told apart from a failed backup.
  • A --<property>=<value> argument, which has already been applied by Spring by that point, is no longer also reported as a failed user.
  • COMMANDS.md, CONFIG.md, USER_GUIDE.md and CHANGELOG.md have been updated, and a 2 row has been added to the Exit Status table.

Behaviour changes worth checking

  • With octocat -i, octocat was previously backed up and a failure was then reported for a user named -i. Nothing is backed up now and status 2 is returned, because arguments are checked before the first backup is started. Backups of the valid names in a scheduled command with a stray option are therefore stopped, although status 1 was already being returned for that command. testRun_InteractiveFlagNotFirst_TreatedAsUserName pinned the old behaviour and has been rewritten as testRun_InteractiveFlagNotFirst_RejectedAsUnknownOption.
  • --<property>=<value> is deliberately not rejected, since a backup that is run that way today would otherwise be stopped. As a result, a mistyped property name is silently ignored.
  • No backup-completed usage event is sent for an unknown-option or --help run, because no backup was run.

Test plan

  • mvn -B -o package: 204 tests were run, with 0 failures, 0 errors and 1 skipped
  • The new tests were confirmed empirically by disabling each branch in turn, since the tests cannot be compiled with the whole change reverted: 3 tests failed with the help branch disabled, 2 with the Spring-property branch disabled, and 4 with the unknown-option branch disabled. All were passed with the code restored.
  • Not verified: the real process status, because launching the JAR was not permitted in this session. The status is covered through SpringApplication.exit by testExitStatus_UnknownOptionReachesSpringApplicationExit. A manual check is recommended: the JAR should be run with --bogus and $? read, and --backup.directory=<path> octocat should be confirmed to write to that path.

Closes #58

Skipped issues

#8 (missing LICENSE) remains deferred: the license text, copyright holder and year have to be chosen by the maintainer.

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

🤖 Generated with Claude Code

Add -h/--help, report any other hyphen-prefixed argument as an unknown
option with exit status 2 before anything is backed up, and leave
--name=value property overrides to Spring instead of also reporting
them as a failed user.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric, scored against the diff at ba2e29d:

  • Scope: PASS — only the runner, its two test classes and the four documents that describe its behaviour were modified.
  • Tests-new: PASS — no public method was added; each new branch is exercised by the 9 new or rewritten tests.
  • Tests-fix: PASS, by mutation rather than stash-and-run — the tests cannot be compiled with the fix reverted, because EXIT_USAGE_ERROR is referenced, so each branch was disabled in turn. 3, 2 and 4 tests failed respectively, and all were passed once the code was restored.
  • Sibling structure: PASS — the COMMANDS.md section follows the heading, Description and Usage shape of the -i section above it.
  • Sibling renames: PASS — no identifier was renamed, apart from the test that pinned the old behaviour.
  • Docs: PASS — COMMANDS.md, CONFIG.md, USER_GUIDE.md and CHANGELOG.md were updated; README.md was not changed because no options are listed in it.
  • Issue resolution: PASS — all four items suggested in Command-line options are treated as GitHub user names, and there is no --help #58 are covered.
  • CI: PASS — build and docker-build were green on ba2e29d.
  • Config-doc parity: PASS — no property was added; the --<property>=<value> form and the backup.progress.overwrite exception were documented.
  • Command-doc parity: PASS — -h, --help and exit status 2 are listed in COMMANDS.md.
  • Package placement: PASS — no class was added.
  • No credential leakage: PASS — only an unrecognized argument is echoed, and a value given as --<property>=<value> is skipped without being printed.

Notes:

  • src/main/java/com/github/backup/BackupCommandLineRunner.java:44 — a --<property>=<value> argument placed before -i means that -i is no longer the first argument, so it is rejected as an unknown option. This is consistent with the documented first-argument rule, and that command was already being failed before this change, so it was left as it is.
  • src/main/java/com/github/backup/BackupCommandLineRunner.java:90 — any --<property>=<value> is skipped, so a mistyped property name is ignored silently. This was accepted, as recorded in the PR description, so that a backup run that way today is not stopped.
  • Not verified: the real process status and a real --backup.directory=<path> override, since launching the JAR was not permitted. The status is covered through SpringApplication.exit. The override relies on the default command-line property source of Spring Boot, which is enabled here because GhBackupApplication passes its arguments to SpringApplication without disabling it.

No FAIL item remains. No review from Copilot could be requested, because the reviewer is not configured on this repository, and no other review comment had been posted.

This review was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit 4d2587c into main Nov 5, 2026
2 checks passed
@dmccoystephenson
dmccoystephenson deleted the feature/cli-option-arguments branch November 5, 2026 04:26
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-line options are treated as GitHub user names, and there is no --help

1 participant