Merge pull request #165 from NobodyXu/fix/arg-parsing

This commit is contained in:
Félix Saparelli 2022-06-07 23:54:42 +12:00 committed by GitHub
commit d7792de0c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,5 @@
use std::{ use std::{
ffi::OsString,
path::PathBuf, path::PathBuf,
process::{ExitCode, Termination}, process::{ExitCode, Termination},
str::FromStr, str::FromStr,
@ -133,7 +134,7 @@ async fn entry() -> Result<()> {
// Filter extraneous arg when invoked by cargo // Filter extraneous arg when invoked by cargo
// `cargo run -- --help` gives ["target/debug/cargo-binstall", "--help"] // `cargo run -- --help` gives ["target/debug/cargo-binstall", "--help"]
// `cargo binstall --help` gives ["/home/ryan/.cargo/bin/cargo-binstall", "binstall", "--help"] // `cargo binstall --help` gives ["/home/ryan/.cargo/bin/cargo-binstall", "binstall", "--help"]
let mut args: Vec<String> = std::env::args().collect(); let mut args: Vec<OsString> = std::env::args_os().collect();
if args.len() > 1 && args[1] == "binstall" { if args.len() > 1 && args[1] == "binstall" {
args.remove(1); args.remove(1);
} }