handle extra subcommand name from cargo

master
Aleš Katona 2 years ago
parent 07d1f8ae46
commit 7f804cedd6
Signed by: almindor
GPG Key ID: 2F773149BF38B48F

@ -1,3 +1,5 @@
use std::ffi::OsString;
use clap::Parser;
mod vcs;
@ -5,7 +7,9 @@ mod vcs;
use vcs::cli::*;
fn main() {
let args = Cli::parse();
// running with cargo vcs causes the vcs arg to be sent along
// we need to unhack this for Clap
let args = parse_args();
let work_dir = args
.path
@ -40,3 +44,15 @@ fn main() {
}
}
}
fn parse_args() -> Cli {
// running with cargo vcs causes the vcs arg to be sent along
// we need to unhack this for Clap
let mut all_args: Vec<OsString> = std::env::args_os().collect();
let vcsstr = String::from("vcs");
let osvcsstr = OsString::from(vcsstr);
if all_args.get(1) == Some(&osvcsstr) {
all_args.remove(1);
}
Cli::parse_from(all_args)
}

Loading…
Cancel
Save