Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make cargo-bisect-rustc work with hyphen or space #362

Merged
merged 1 commit into from
Dec 31, 2024

Conversation

ehuss
Copy link
Collaborator

@ehuss ehuss commented Dec 31, 2024

This makes it so that the executable name cargo-bisect-rustc (with a hyphen) works the same as cargo bisect-rustc (with a space). This fixes parsing problems when used with a space as demonstrated in #359.

Previously, cbr would try to support both forms, but it didn't always work (see #359). This is due to the way it was trying to do a fallback parsing without the subcommand, which means CLI parsing errors when used as a subcommand to not work (since the original error was discarded).

The solution is to not attempt to use clap to do subcommand handling, and instead just strip the bisect-rustc subcommand if it exists.

Other than fixing the errors, one observable change is that cargo-bisect-rustc (without a space, with no arguments) will now behave the same as cargo bisect-rustc (it will start the bisection process). Previously it would print a somewhat confusing error about the missing bisect-rustc subcommand. This also apples to --help and -h.

Fixes #359

// `cargo bisect-rustc` (with a space) to work identically.
if let Some(command) = os_args.get(1) {
if command == "bisect-rustc" {
os_args.remove(1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird that we don't need to adjust arg 0 to show "the right" (whatever that means) command. The output seems to look right

@oli-obk oli-obk merged commit 9c638ea into rust-lang:master Dec 31, 2024
4 checks passed
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.

Unexpected arguments are incorrectly identified
2 participants