From 40d7c7af956d411553c31943f0a843bf0df1b666 Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Wed, 2 Jun 2021 00:33:27 +0800 Subject: [PATCH] feat: args --- src/cmd_plist_default.rs | 7 +++++-- src/find.rs | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cmd_plist_default.rs b/src/cmd_plist_default.rs index 70bf0a0..12b34b0 100644 --- a/src/cmd_plist_default.rs +++ b/src/cmd_plist_default.rs @@ -25,7 +25,7 @@ impl CommandImpl { .help("Output plist format") ) .arg(Arg::with_name("out").short("o").long("out").takes_value(true).help("Output plist file")) - .arg(Arg::with_name("FILE").required(true).index(1).help("Input plist file name")) + .arg(Arg::with_name("FILE").index(1).help("Input plist file name")) } pub fn run(matches: &ArgMatches) -> CommandError { let parsed_args = parse_args(matches); @@ -70,8 +70,11 @@ impl CommandImpl { } fn parse_args(matches: &ArgMatches) -> ParsedArgs { + let in_file = matches.value_of("FILE").map(ToString::to_string).unwrap_or_else(|| { + failure_and_exit!("FILE IS NOT ASSIGNED, SUPPORT STD IN LATER."); + }); ParsedArgs { - in_file: matches.value_of("FILE").unwrap().to_string(), + in_file, format: match matches.value_of("format") { Some("xml") => PlistFormat::Xml, Some("bin") | Some("binary") => PlistFormat::Binary, diff --git a/src/find.rs b/src/find.rs index ef023fa..903da10 100644 --- a/src/find.rs +++ b/src/find.rs @@ -26,7 +26,7 @@ fn find_value(value: &Value, path: &mut Vec, find_val: &str) -> Vec<(Str ret.push((make_path(path), b.to_string())); } Value::Data(_data) => { - warning!("Ignored key: {}", make_path(path)); + debugging!("Ignored key: {}", make_path(path)); } Value::Date(_date) => { /* IGNORE */ } Value::Dictionary(dict) => {