Skip to content

Commit

Permalink
fix: Version flag, no parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Dustin Blackman committed Jan 1, 2024
1 parent 416012f commit e00ebe3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ pub fn run() -> Result<()> {
.num_args(0)
.help("Print help");

let arg_version = Arg::new("version")
.short('V')
.long("version")
.num_args(0)
.help("Print version");

// @deprecated: Use --install.
let arg_build = Arg::new("build")
.short('b')
Expand All @@ -95,17 +101,20 @@ pub fn run() -> Result<()> {
.version(env!("CARGO_PKG_VERSION"))
.arg_required_else_help(false)
.ignore_errors(true)
.disable_version_flag(true)
.arg(arg_sync_aliases.clone())
.arg(arg_install.clone())
.arg(arg_build.clone())
.arg(arg_version.clone())
.subcommand(
Command::new("bin")
.hide(true)
.disable_help_flag(true)
.arg(arg_sync_aliases)
.arg(arg_install)
.arg(arg_build)
.arg(arg_help),
.arg(arg_help)
.arg(arg_version),
);

let matches = app.clone().get_matches();
Expand All @@ -116,6 +125,8 @@ pub fn run() -> Result<()> {
install_all_binaries()?;
} else if arg_used(&matches, "help") {
app.print_long_help()?;
} else if arg_used(&matches, "version") {
println!("cargo-run-bin {}", env!("CARGO_PKG_VERSION"));
} else {
let mut args: Vec<_> = env::args().collect();
let start_index = args
Expand All @@ -132,6 +143,7 @@ pub fn run() -> Result<()> {
}
if bin_index >= args.len() {
app.print_long_help()?;
return Ok(());
}

let binary_name = args[bin_index].clone();
Expand Down

0 comments on commit e00ebe3

Please sign in to comment.