aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-06-02 21:54:34 +0000
committerFuwn <[email protected]>2021-06-02 21:54:34 +0000
commitf519cbbd79a0a8918331e0f4e7c5ae8b48c19bc2 (patch)
tree0bfa044d8e37490a2228d3c1751186bedfd809e2
parentrefactor(process): nitrous as hidden directory (diff)
downloadnitrous-f519cbbd79a0a8918331e0f4e7c5ae8b48c19bc2.tar.xz
nitrous-f519cbbd79a0a8918331e0f4e7c5ae8b48c19bc2.zip
refactor(cli): new subcommand matching format
-rw-r--r--.nitrous/check/invalid.txt2
-rw-r--r--.nitrous/check/valid.txt0
-rw-r--r--.nitrous/codes.txt2
-rw-r--r--src/cli.rs78
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
diff --git a/src/cli.rs b/src/cli.rs
index 3b1046d..1dd4631 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -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!(),
}
}