From 292ca29618927792eeadf9fef7ec5d7be32f397d Mon Sep 17 00:00:00 2001 From: joewnga Date: Thu, 18 Jul 2024 21:16:56 +0300 Subject: [PATCH 1/3] Fix: Ensure --version flag works correctly for cargo stylus - Resolved duplication of command 'check' alias 'c' --- main/src/main.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/main/src/main.rs b/main/src/main.rs index 7ffa008..30ea391 100644 --- a/main/src/main.rs +++ b/main/src/main.rs @@ -2,7 +2,7 @@ // For licensing, see https://github.com/OffchainLabs/cargo-stylus/blob/main/licenses/COPYRIGHT.md use cargo_stylus_util::{color::Color, sys}; -use clap::Parser; +use clap::{CommandFactory, Parser}; use eyre::{bail, Result}; // Conditional import for Unix-specific `CommandExt` @@ -34,7 +34,7 @@ enum Subcommands { /// Export a Solidity ABI. ExportAbi, /// Cache a contract. - #[command(alias = "c")] + #[command(alias = "a")] Cache, /// Check a contract. #[command(alias = "c")] @@ -78,6 +78,7 @@ const COMMANDS: &[Binary] = &[ "reproducible", "n", "x", + "a", "c", "d", "v", @@ -102,13 +103,13 @@ const COMMANDS: &[Binary] = &[ ]; fn exit_with_help_msg() -> ! { - Opts::parse_from(["--help"]); - unreachable!() + Opts::command().print_help().unwrap(); + std::process::exit(0); } fn exit_with_version() -> ! { - Opts::parse_from(["--version"]); - unreachable!() + println!("{}", Opts::command().render_version()); + std::process::exit(0); } fn main() -> Result<()> { From 1d6fb45f24aead9b101a7493952a98b4a7748e3d Mon Sep 17 00:00:00 2001 From: joewnga <66113453+joewnga@users.noreply.github.com> Date: Thu, 25 Jul 2024 09:30:41 +0300 Subject: [PATCH 2/3] added documentation comments for the help and version info functions --- main/src/main.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main/src/main.rs b/main/src/main.rs index 30ea391..7eb259b 100644 --- a/main/src/main.rs +++ b/main/src/main.rs @@ -102,11 +102,13 @@ const COMMANDS: &[Binary] = &[ }, ]; +// prints help message and exits fn exit_with_help_msg() -> ! { Opts::command().print_help().unwrap(); std::process::exit(0); } +// prints version information and exits fn exit_with_version() -> ! { println!("{}", Opts::command().render_version()); std::process::exit(0); From 2e5acea61d7041e256b4f329bb2c0c36c2037bfc Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Fri, 26 Jul 2024 12:15:23 -0500 Subject: [PATCH 3/3] Apply suggestions from code review --- main/src/main.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/main/src/main.rs b/main/src/main.rs index 7eb259b..43da340 100644 --- a/main/src/main.rs +++ b/main/src/main.rs @@ -34,7 +34,6 @@ enum Subcommands { /// Export a Solidity ABI. ExportAbi, /// Cache a contract. - #[command(alias = "a")] Cache, /// Check a contract. #[command(alias = "c")] @@ -78,7 +77,6 @@ const COMMANDS: &[Binary] = &[ "reproducible", "n", "x", - "a", "c", "d", "v",