Skip to content

feat(git-remote-gitlawb): add --version and --help flags#30

Open
FrozenRaspberry wants to merge 1 commit into
Gitlawb:mainfrom
FrozenRaspberry:feat/git-remote-version-flag
Open

feat(git-remote-gitlawb): add --version and --help flags#30
FrozenRaspberry wants to merge 1 commit into
Gitlawb:mainfrom
FrozenRaspberry:feat/git-remote-version-flag

Conversation

@FrozenRaspberry
Copy link
Copy Markdown

@FrozenRaspberry FrozenRaspberry commented Jun 7, 2026

What

Adds --version/-V and --help/-h to git-remote-gitlawb.

Why

git-remote-gitlawb is the only workspace binary without --version, which is called out in:

  • docs/MAINTAINER-ROADMAP.md"Add --version support to git-remote-gitlawb so release smoke tests can validate it directly."
  • docs/OSS-READINESS-AUDIT.md"git-remote-gitlawb has no --version flag; release smoke tests should use a helper-specific invocation."

How

  • --version/-V prints git-remote-gitlawb <version>, matching the <bin> <version> format the clap-based gl and gitlawb-node emit, so release tooling can treat all three binaries uniformly. The version comes from CARGO_PKG_VERSION, so it tracks the workspace version automatically.
  • --help/-h prints concise usage (URL form, env vars, flags).
  • Flags are recognized only as the first argument, so git's <remote-name> <url> remote-helper invocation path is completely untouched. A remote literally named --version is not mistaken for the flag (covered by a test).
  • Informational flags are handled before tracing init so the output stays clean for scripts/smoke tests.

No protocol or API changes. Purely additive, no breaking changes.

Testing

  • cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings, and cargo test -p git-remote-gitlawb all pass.
  • 8 new unit tests cover argument classification (including the no-args and misplaced-flag edge cases) and the version/help strings.
  • Manually verified on a release build:
    • git-remote-gitlawb --versiongit-remote-gitlawb 0.3.9
    • --help renders the usage text
    • no-args still exits 1 with a usage hint

Follow-up (separate PR)

This unblocks per-binary release smoke tests. I'm happy to send a small follow-up wiring --version checks for all three binaries into release.yml (the audit also notes "release binaries are not smoke-tested after packaging") — kept out of this PR to keep it focused on one change.

Summary by CodeRabbit

  • New Features
    • Added --version flag to display application version information
    • Added --help flag to display usage documentation
    • Improved error messages to guide users to help resources

git-remote-gitlawb was the only workspace binary without `--version`, so
release smoke tests could not validate the packaged helper directly. This
is called out in docs/MAINTAINER-ROADMAP.md ("Add --version support to
git-remote-gitlawb so release smoke tests can validate it directly") and
docs/OSS-READINESS-AUDIT.md.

- `--version`/`-V` prints `git-remote-gitlawb <version>`, matching the
  `<bin> <version>` format the clap-based `gl` and `gitlawb-node` emit so
  release tooling can treat all three binaries uniformly. The version
  comes from CARGO_PKG_VERSION.
- `--help`/`-h` prints concise usage (URL form, env vars, flags).
- Flags are only recognized as the first argument, so git's
  `<remote-name> <url>` remote-helper invocation path is untouched; a
  remote literally named "--version" is not mistaken for the flag.
- Informational flags are handled before tracing init so output stays
  clean for scripts.

Adds unit tests for argument classification (including the no-args and
misplaced-flag edge cases) and the version/help strings.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 7, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ce976a98-41ef-437d-8eec-585051dd7309

📥 Commits

Reviewing files that changed from the base of the PR and between 6abaf1d and c6852e7.

📒 Files selected for processing (1)
  • crates/git-remote-gitlawb/src/main.rs

📝 Walkthrough

Walkthrough

The pull request adds CLI flag support to the git-remote-gitlawb binary. The main function is refactored to collect arguments early, classify and handle --version and --help flags before initializing logging, then exit cleanly. Supporting functions implement flag classification and output formatting. Tests validate the flag parsing and output generation.

Changes

CLI Flag Handling

Layer / File(s) Summary
Main function early flag handling
crates/git-remote-gitlawb/src/main.rs
Arguments are collected at startup before logging initialization. The --version and --help flags are classified early and processed immediately, with output printed to stdout and clean exit. Logging is moved after flag handling. Usage error message gains a help hint directing users to --help.
Flag classification and output formatting
crates/git-remote-gitlawb/src/main.rs
New Invocation enum declares Version, Help, and Helper cases. classify_args() matches first argument against flag patterns. version_line() formats a version string matching release-tool conventions. help_text() generates formatted help documentation describing usage, environment variables, and available flags.
CLI argument and output tests
crates/git-remote-gitlawb/src/main.rs
Helper function args() converts string slices to Vec. Five tests verify classify_args() handles long/short flags, normal invocation, edge cases, and flag-position specificity. Two tests validate version_line() and help_text() output formatting and content.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit hops through argparse today,
With --help and --version flags on display,
Early escape before logging takes flight,
Clean output and tests make the code shine bright! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding --version and --help flags to the git-remote-gitlawb binary, which is the primary objective of this pull request.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant