From 7dd275f01e1b094741981bf98177532503076790 Mon Sep 17 00:00:00 2001 From: Alex Macleod Date: Thu, 1 Sep 2022 13:33:40 +0000 Subject: [PATCH] Fix the CLI requiring the help argument --- .github/workflows/ci.yml | 2 +- src/main.rs | 9 +-------- tests/cmd/{h.sterr => bare-h.stderr} | 0 tests/cmd/bare-h.stdout | 11 +++++++++++ tests/cmd/bare-h.toml | 2 ++ tests/cmd/bare-help.stderr | 0 tests/cmd/bare-help.stdout | 11 +++++++++++ tests/cmd/bare-help.toml | 2 ++ tests/cmd/h.toml | 2 +- tests/cmd/help.toml | 2 +- tests/cmd/start-in-future.stderr | 1 + tests/cmd/start-in-future.stdout | 0 tests/cmd/start-in-future.toml | 3 +++ 13 files changed, 34 insertions(+), 11 deletions(-) rename tests/cmd/{h.sterr => bare-h.stderr} (100%) create mode 100644 tests/cmd/bare-h.stdout create mode 100644 tests/cmd/bare-h.toml create mode 100644 tests/cmd/bare-help.stderr create mode 100644 tests/cmd/bare-help.stdout create mode 100644 tests/cmd/bare-help.toml create mode 100644 tests/cmd/start-in-future.stderr create mode 100644 tests/cmd/start-in-future.stdout create mode 100644 tests/cmd/start-in-future.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 63da447..e4307d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,4 +31,4 @@ jobs: - name: Verify that binary works run: | cargo run -- bisect-rustc --help | grep "EXAMPLES:" - cargo run -- --help | grep "EXAMPLES:" + cargo run -- --help | grep "SUBCOMMANDS:" diff --git a/src/main.rs b/src/main.rs index 50764fc..40bf050 100644 --- a/src/main.rs +++ b/src/main.rs @@ -57,11 +57,7 @@ const REPORT_HEADER: &str = "\ =================================================================================="; #[derive(Debug, Parser)] -#[clap( - bin_name = "cargo", - disable_help_flag = true, - subcommand_required = true -)] +#[clap(bin_name = "cargo", subcommand_required = true)] enum Cargo { BisectRustc(Opts), } @@ -85,9 +81,6 @@ enum Cargo { )] #[allow(clippy::struct_excessive_bools)] struct Opts { - #[clap(long, short, action = clap::builder::ArgAction::Help, help = "Print help information")] - help: bool, - #[clap( long, help = "Custom regression definition", diff --git a/tests/cmd/h.sterr b/tests/cmd/bare-h.stderr similarity index 100% rename from tests/cmd/h.sterr rename to tests/cmd/bare-h.stderr diff --git a/tests/cmd/bare-h.stdout b/tests/cmd/bare-h.stdout new file mode 100644 index 0000000..29c7f1f --- /dev/null +++ b/tests/cmd/bare-h.stdout @@ -0,0 +1,11 @@ +cargo-bisect-rustc + +USAGE: + cargo + +OPTIONS: + -h, --help Print help information + +SUBCOMMANDS: + bisect-rustc Bisects rustc toolchains with rustup + help Print this message or the help of the given subcommand(s) diff --git a/tests/cmd/bare-h.toml b/tests/cmd/bare-h.toml new file mode 100644 index 0000000..020e6f6 --- /dev/null +++ b/tests/cmd/bare-h.toml @@ -0,0 +1,2 @@ +bin.name = "cargo-bisect-rustc" +args = "-h" diff --git a/tests/cmd/bare-help.stderr b/tests/cmd/bare-help.stderr new file mode 100644 index 0000000..e69de29 diff --git a/tests/cmd/bare-help.stdout b/tests/cmd/bare-help.stdout new file mode 100644 index 0000000..29c7f1f --- /dev/null +++ b/tests/cmd/bare-help.stdout @@ -0,0 +1,11 @@ +cargo-bisect-rustc + +USAGE: + cargo + +OPTIONS: + -h, --help Print help information + +SUBCOMMANDS: + bisect-rustc Bisects rustc toolchains with rustup + help Print this message or the help of the given subcommand(s) diff --git a/tests/cmd/bare-help.toml b/tests/cmd/bare-help.toml new file mode 100644 index 0000000..a10767f --- /dev/null +++ b/tests/cmd/bare-help.toml @@ -0,0 +1,2 @@ +bin.name = "cargo-bisect-rustc" +args = "--help" diff --git a/tests/cmd/h.toml b/tests/cmd/h.toml index 020e6f6..7e0c55f 100644 --- a/tests/cmd/h.toml +++ b/tests/cmd/h.toml @@ -1,2 +1,2 @@ bin.name = "cargo-bisect-rustc" -args = "-h" +args = "bisect-rustc -h" diff --git a/tests/cmd/help.toml b/tests/cmd/help.toml index a10767f..abd7ae3 100644 --- a/tests/cmd/help.toml +++ b/tests/cmd/help.toml @@ -1,2 +1,2 @@ bin.name = "cargo-bisect-rustc" -args = "--help" +args = "bisect-rustc --help" diff --git a/tests/cmd/start-in-future.stderr b/tests/cmd/start-in-future.stderr new file mode 100644 index 0000000..eb3a38c --- /dev/null +++ b/tests/cmd/start-in-future.stderr @@ -0,0 +1 @@ +ERROR: start date must be on or before the current date. received start date request 9999-01-01UTC diff --git a/tests/cmd/start-in-future.stdout b/tests/cmd/start-in-future.stdout new file mode 100644 index 0000000..e69de29 diff --git a/tests/cmd/start-in-future.toml b/tests/cmd/start-in-future.toml new file mode 100644 index 0000000..728ca92 --- /dev/null +++ b/tests/cmd/start-in-future.toml @@ -0,0 +1,3 @@ +bin.name = "cargo-bisect-rustc" +args = "--start 9999-01-01" +status = "failed"