-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlib.rs
40 lines (36 loc) · 1.06 KB
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use std::process;
use clap::{App, Arg};
mod all;
mod file;
mod git;
mod http;
mod new;
mod render;
pub async fn run() {
let matches = App::new("leetcode")
.version("0.0.1")
.author("bestgopher <84328409@qq.com>")
.about("a helper for leetcode")
.subcommand(
App::new("new").about("get a new leetcode question").arg(
Arg::new("question_name")
.help("The configuration file to use")
.index(1),
),
)
.subcommand(App::new("all").about("get all questions' info and rewrite README.md"))
.get_matches();
if let Some(matches) = matches.subcommand_matches("new") {
match matches.value_of_t::<String>("question_name") {
Ok(x) => new::new(x).await,
Err(_) => {
eprintln!("please input the name of question");
process::exit(1);
}
}
} else if matches.subcommand_matches("all").is_some() {
all::all().await;
} else {
git::push().await;
}
}