Skip to content

Commit

Permalink
allow usage of cargo bisect-rustc and cargo-bisect-rustc
Browse files Browse the repository at this point in the history
  • Loading branch information
Emilgardis committed Aug 4, 2022
1 parent 78c1265 commit 3a11758
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: cargo test
- name: Verify that binary works
run: |
cargo run -- bisect-rustc --help | grep "EXAMPLES:"
cargo run -- --help | grep "EXAMPLES:"
25 changes: 24 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ const REPORT_HEADER: &str = "\

#[derive(Debug, Parser)]
#[clap(
bin_name = "cargo",
disable_help_flag = true,
subcommand_required = true
)]
enum Cargo {
BisectRustc(Opts),
}

#[derive(Debug, Parser)]
#[clap(
bin_name = "cargo bisect-rustc",
version,
about,
after_help = "EXAMPLES:
Expand All @@ -74,6 +85,9 @@ const REPORT_HEADER: &str = "\
)]
#[allow(clippy::struct_excessive_bools)]
struct Opts {
#[clap(long, short, action = clap::builder::ArgAction::Help)]
help: bool,

#[clap(
long,
help = "Custom regression definition",
Expand Down Expand Up @@ -558,7 +572,16 @@ fn check_bounds(start: &Option<Bound>, end: &Option<Bound>) -> anyhow::Result<()
// Application entry point
fn run() -> anyhow::Result<()> {
env_logger::try_init()?;
let mut args = Opts::parse();
let mut args = match Cargo::try_parse() {
Ok(Cargo::BisectRustc(args)) => args,
Err(e) => match e.context().next() {
None => {
Cargo::parse();
unreachable!()
}
_ => Opts::parse(),
},
};
fixup_bounds(&args.access, &mut args.start, &mut args.end)?;
check_bounds(&args.start, &args.end)?;
let cfg = Config::from_args(args)?;
Expand Down

0 comments on commit 3a11758

Please sign in to comment.