Support --help / -h on the command-line tool - #568
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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