Skip to content

Support --help / -h on the command-line tool - #568

Merged
brawer merged 1 commit into
mainfrom
cli-help-flag
Aug 10, 2026
Merged

Support --help / -h on the command-line tool#568
brawer merged 1 commit into
mainfrom
cli-help-flag

Conversation

@brawer

@brawer brawer commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Follow-up from #563.

Same story as `--version`: `--help` previously failed with `error: unexpected argument found`, since clap runs with a minimal feature set here (`default-features = false`, only `derive` + `std`). Unlike `--version`, though, `--help` genuinely needs more -- confirmed by testing incrementally:

  • clap's `help` feature is what makes `-h`/`--help` exist at all
  • `usage` is separately needed to fill in the actual `Usage: ...` line (with only `help` added, `--help` worked but printed a blank `Usage:` with nothing after it)

Neither feature pulls in any new dependency -- `Cargo.lock` is unchanged.

Also added doc comments on `Cli`, the `Run` variant, and its `workdir` field, since clap derives their `--help` descriptions from those -- without them, every entry in the Commands/Options list was blank. Now `--help` actually explains what the tool and its subcommand do.

One behavior worth knowing about, not a bug (confirmed by testing, not assumed): the `Usage:` line's program name (`osm-diffs`) differs from what `--version` reports (`diffed-places-pipeline 0.6.0`). That's intentional clap behavior -- the usage line reflects how the binary was actually invoked at runtime (`argv[0]`), while `--version` uses the compile-time `name` override.

Testing

Full `cargo test` (added `test_help_flag` alongside the existing `test_version_flag`, asserting on stable substrings rather than exact output), `cargo fmt --check`, and `cargo clippy --locked` all clean. Manually ran `--help`, `-h`, and `run --help` to confirm actual output content.

🤖 Generated with Claude Code

Same story as --version (#563): --help previously failed with
"error: unexpected argument found" because clap runs with a minimal
feature set here (default-features = false, only "derive" + "std").
Unlike --version, though, --help genuinely needs more: clap's "help"
feature is what makes -h/--help exist at all, and "usage" is what
fills in the actual "Usage: ..." line (confirmed by testing
incrementally -- with only "help" added, --help worked but printed
a blank "Usage:" line with nothing after it).

Neither feature pulled in any new dependencies -- Cargo.lock is
unchanged.

Also added doc comments on Cli, the Run variant, and its workdir
field, since clap derives their --help descriptions from those doc
comments -- without them every entry in the Commands/Options list
was blank. Now `--help` actually explains what the tool and its one
subcommand do, not just successfully print an empty shell.

One behavior worth knowing, not a bug: the "Usage:" line's program
name ("osm-diffs") differs from what --version reports
("diffed-places-pipeline 0.6.0"). That's intentional clap behavior --
the usage line reflects how the binary was actually invoked at
runtime (argv[0]), while --version uses the compile-time `name`
override. Confirmed by testing directly, not assumed.

Verified: cargo build, full cargo test (added test_help_flag
alongside the existing test_version_flag, asserting on stable
substrings rather than exact output), cargo fmt --check, and
cargo clippy --locked all clean. Manually ran --help, -h, and
`run --help` to confirm actual output content.
@brawer
brawer enabled auto-merge August 10, 2026 06:22
@brawer
brawer added this pull request to the merge queue Aug 10, 2026
Merged via the queue into main with commit d17d4d5 Aug 10, 2026
4 checks passed
@brawer
brawer deleted the cli-help-flag branch August 10, 2026 06:29
@brawer brawer added the bug Something isn't working label Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant