diff options
| -rw-r--r-- | .nitrous/check/invalid.txt | 2 | ||||
| -rw-r--r-- | .nitrous/check/valid.txt | 0 | ||||
| -rw-r--r-- | .nitrous/codes.txt | 2 | ||||
| -rw-r--r-- | src/cli.rs | 78 |
4 files changed, 44 insertions, 38 deletions
diff --git a/.nitrous/check/invalid.txt b/.nitrous/check/invalid.txt new file mode 100644 index 0000000..03401f4 --- /dev/null +++ b/.nitrous/check/invalid.txt @@ -0,0 +1,2 @@ +sDEsEecZpXFYQOm7 +HTU8AnniCTB1XOhj diff --git a/.nitrous/check/valid.txt b/.nitrous/check/valid.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.nitrous/check/valid.txt diff --git a/.nitrous/codes.txt b/.nitrous/codes.txt new file mode 100644 index 0000000..03401f4 --- /dev/null +++ b/.nitrous/codes.txt @@ -0,0 +1,2 @@ +sDEsEecZpXFYQOm7 +HTU8AnniCTB1XOhj @@ -37,49 +37,51 @@ impl Cli { let debug = matches.is_present("debug"); - if matches.is_present("generate") { - Nitrous::generate( - matches - .subcommand_matches("generate") - .unwrap() - .value_of("amount") - .unwrap() - .to_string() - .parse::<usize>() - .unwrap(), - debug, - ); - } else if matches.is_present("check") { - Nitrous::check( - { - let argument = matches - .subcommand_matches("check") + match matches.subcommand() { + ("generate", _) => + Nitrous::generate( + matches + .subcommand_matches("generate") .unwrap() - .value_of("file"); - if argument.is_some() { - argument.unwrap() - } else if std::fs::File::open(".nitrous/codes.txt").is_err() { - panic!("cannot open nitrous generated codes.txt"); - } else { - ".nitrous/codes.txt" - } - }, - debug, - ProxyType::from_str( + .value_of("amount") + .unwrap() + .to_string() + .parse::<usize>() + .unwrap(), + debug, + ), + ("check", _) => + Nitrous::check( + { + let argument = matches + .subcommand_matches("check") + .unwrap() + .value_of("file"); + if argument.is_some() { + argument.unwrap() + } else if std::fs::File::open(".nitrous/codes.txt").is_err() { + panic!("cannot open nitrous generated codes.txt"); + } else { + ".nitrous/codes.txt" + } + }, + debug, + ProxyType::from_str( + matches + .subcommand_matches("check") + .unwrap() + .value_of("proxy_type") + .unwrap(), + ) + .unwrap(), matches .subcommand_matches("check") .unwrap() - .value_of("proxy_type") - .unwrap(), + .value_of("proxy_list") + .unwrap_or("null"), ) - .unwrap(), - matches - .subcommand_matches("check") - .unwrap() - .value_of("proxy_list") - .unwrap_or("null"), - ) - .await; + .await, + _ => unreachable!(), } } |