diff --git a/src/main.rs b/src/main.rs index b8becf8..7a43f23 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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 = 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) +}