Use Arguments::from_os

This commit is contained in:
Aleksey Kladov 2020-02-17 17:12:37 +01:00
parent 57140f1730
commit 0353e1c6f4

View File

@ -40,16 +40,10 @@ impl Verbosity {
fn main() -> Result<()> { fn main() -> Result<()> {
env_logger::try_init()?; env_logger::try_init()?;
let subcommand = match std::env::args_os().nth(1) { let mut matches = Arguments::from_env();
None => { let subcommand = matches.subcommand()?.unwrap_or_default();
eprintln!("{}", help::GLOBAL_HELP);
return Ok(());
}
Some(s) => s,
};
let mut matches = Arguments::from_vec(std::env::args_os().skip(2).collect());
match &*subcommand.to_string_lossy() { match subcommand.as_str() {
"parse" => { "parse" => {
if matches.contains(["-h", "--help"]) { if matches.contains(["-h", "--help"]) {
eprintln!("{}", help::PARSE_HELP); eprintln!("{}", help::PARSE_HELP);