feat: args

This commit is contained in:
2021-06-02 00:33:27 +08:00
parent 635bbe6e72
commit 40d7c7af95
2 changed files with 6 additions and 3 deletions

View File

@@ -25,7 +25,7 @@ impl CommandImpl {
.help("Output plist format") .help("Output plist format")
) )
.arg(Arg::with_name("out").short("o").long("out").takes_value(true).help("Output plist file")) .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 { pub fn run(matches: &ArgMatches) -> CommandError {
let parsed_args = parse_args(matches); let parsed_args = parse_args(matches);
@@ -70,8 +70,11 @@ impl CommandImpl {
} }
fn parse_args(matches: &ArgMatches) -> ParsedArgs { 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 { ParsedArgs {
in_file: matches.value_of("FILE").unwrap().to_string(), in_file,
format: match matches.value_of("format") { format: match matches.value_of("format") {
Some("xml") => PlistFormat::Xml, Some("xml") => PlistFormat::Xml,
Some("bin") | Some("binary") => PlistFormat::Binary, Some("bin") | Some("binary") => PlistFormat::Binary,

View File

@@ -26,7 +26,7 @@ fn find_value(value: &Value, path: &mut Vec<String>, find_val: &str) -> Vec<(Str
ret.push((make_path(path), b.to_string())); ret.push((make_path(path), b.to_string()));
} }
Value::Data(_data) => { Value::Data(_data) => {
warning!("Ignored key: {}", make_path(path)); debugging!("Ignored key: {}", make_path(path));
} }
Value::Date(_date) => { /* IGNORE */ } Value::Date(_date) => { /* IGNORE */ }
Value::Dictionary(dict) => { Value::Dictionary(dict) => {