Skip to content

Commit 44298b9

Browse files
authored
Merge pull request #187 from Emilgardis/fix186
allow usage of `cargo bisect-rustc` and `cargo-bisect-rustc`
2 parents e32c97d + 4f286bc commit 44298b9

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@ jobs:
2828
env:
2929
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3030
run: cargo test
31+
- name: Verify that binary works
32+
run: |
33+
cargo run -- bisect-rustc --help | grep "EXAMPLES:"
34+
cargo run -- --help | grep "EXAMPLES:"

src/main.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ const REPORT_HEADER: &str = "\
5858

5959
#[derive(Debug, Parser)]
6060
#[clap(
61+
bin_name = "cargo",
62+
disable_help_flag = true,
63+
subcommand_required = true
64+
)]
65+
enum Cargo {
66+
BisectRustc(Opts),
67+
}
68+
69+
#[derive(Debug, Parser)]
70+
#[clap(
71+
bin_name = "cargo bisect-rustc",
6172
version,
6273
about,
6374
after_help = "EXAMPLES:
@@ -74,6 +85,9 @@ const REPORT_HEADER: &str = "\
7485
)]
7586
#[allow(clippy::struct_excessive_bools)]
7687
struct Opts {
88+
#[clap(long, short, action = clap::builder::ArgAction::Help, help = "Print help information")]
89+
help: bool,
90+
7791
#[clap(
7892
long,
7993
help = "Custom regression definition",
@@ -558,7 +572,16 @@ fn check_bounds(start: &Option<Bound>, end: &Option<Bound>) -> anyhow::Result<()
558572
// Application entry point
559573
fn run() -> anyhow::Result<()> {
560574
env_logger::try_init()?;
561-
let mut args = Opts::parse();
575+
let mut args = match Cargo::try_parse() {
576+
Ok(Cargo::BisectRustc(args)) => args,
577+
Err(e) => match e.context().next() {
578+
None => {
579+
Cargo::parse();
580+
unreachable!()
581+
}
582+
_ => Opts::parse(),
583+
},
584+
};
562585
fixup_bounds(&args.access, &mut args.start, &mut args.end)?;
563586
check_bounds(&args.start, &args.end)?;
564587
let cfg = Config::from_args(args)?;

tests/cmd/h.stdout

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cargo-bisect-rustc 0.6.4
22
Bisects rustc toolchains with rustup
33

44
USAGE:
5-
cargo-bisect-rustc[EXE] [OPTIONS] [-- <COMMAND_ARGS>...]
5+
cargo bisect-rustc [OPTIONS] [-- <COMMAND_ARGS>...]
66

77
ARGS:
88
<COMMAND_ARGS>... Arguments to pass to cargo or the file specified by --script during

tests/cmd/help.stdout

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cargo-bisect-rustc 0.6.4
22
Bisects rustc toolchains with rustup
33

44
USAGE:
5-
cargo-bisect-rustc[EXE] [OPTIONS] [-- <COMMAND_ARGS>...]
5+
cargo bisect-rustc [OPTIONS] [-- <COMMAND_ARGS>...]
66

77
ARGS:
88
<COMMAND_ARGS>... Arguments to pass to cargo or the file specified by --script during

0 commit comments

Comments
 (0)