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

Fix: Ensure --version flag works correctly for cargo stylus #55

Merged
merged 3 commits into from
Jul 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions main/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -34,7 +34,6 @@ enum Subcommands {
/// Export a Solidity ABI.
ExportAbi,
/// Cache a contract.
#[command(alias = "c")]
Cache,
/// Check a contract.
#[command(alias = "c")]
Expand Down Expand Up @@ -101,14 +100,16 @@ const COMMANDS: &[Binary] = &[
},
];

// prints help message and exits
fn exit_with_help_msg() -> ! {
Opts::parse_from(["--help"]);
unreachable!()
Opts::command().print_help().unwrap();
std::process::exit(0);
}

// prints version information and exits
fn exit_with_version() -> ! {
Opts::parse_from(["--version"]);
unreachable!()
println!("{}", Opts::command().render_version());
std::process::exit(0);
}

fn main() -> Result<()> {
Expand Down
Loading