Skip to content

fix(cli): fix cargo subcommand invocation and flag parsing#5

Merged
rocketman-code merged 1 commit intomainfrom
fix/cargo-subcommand-parsing
Feb 23, 2026
Merged

fix(cli): fix cargo subcommand invocation and flag parsing#5
rocketman-code merged 1 commit intomainfrom
fix/cargo-subcommand-parsing

Conversation

@rocketman-code
Copy link
Owner

Summary

  • Fixed cargo avail invocation being completely broken — subcommand stripping never fired because it checked argv[0] == "cargo" but cargo invokes the binary as "cargo-avail"
  • Removed allow_hyphen_values which caused all flags (--json, --version, --quiet, --available-only) to be swallowed as crate names when any positional arg preceded them
  • Added 3 new CLI tests covering subcommand stripping, flags-after-positionals, and cargo subcommand flag forwarding

Test plan

  • cargo test --workspace — 38 passed, 0 failed
  • cargo clippy --workspace --all-targets -- -D warnings — clean
  • Manual verification: cargo avail --version, cargo avail --help, cargo avail serde, cargo avail std --json, cargo avail --quiet serde, stdin piping, canonical dedup, -- separator for hyphen names

Fix subcommand stripping that was dead code (checked argv[0] == "cargo"
but cargo sets argv[0] to binary path). Use CARGO env var to detect
cargo subcommand invocation, only stripping argv[1] == "avail" when
invoked via cargo. Remove allow_hyphen_values which caused flags after
positional args to be swallowed as crate names.
@rocketman-code rocketman-code force-pushed the fix/cargo-subcommand-parsing branch from ee26ec1 to e41cea4 Compare February 23, 2026 02:42
@rocketman-code rocketman-code merged commit 7efac75 into main Feb 23, 2026
6 of 7 checks passed
@rocketman-code rocketman-code deleted the fix/cargo-subcommand-parsing branch February 23, 2026 02:44
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