|
1 | | -use clap::{App, AppSettings, Arg}; |
| 1 | +use clap::{App, AppSettings, Arg, SubCommand}; |
2 | 2 |
|
3 | 3 | const PKG_VERSION: Option<&'static str> = option_env!("CARGO_PKG_VERSION"); |
4 | 4 |
|
5 | | -pub fn build_cli() -> App<'static> { |
| 5 | +pub fn build_cli() -> App<'static, 'static> { |
6 | 6 | App::new("Test My Code client written in Rust") |
7 | 7 | .setting(AppSettings::ArgRequiredElseHelp) |
8 | 8 | .version(PKG_VERSION.unwrap()) |
9 | 9 | .about("Client for downloading, testing and submitting exercises through the Test My Code system") |
10 | | - .subcommand(App::new("courses").about("List the available courses")) |
| 10 | + .subcommand(SubCommand::with_name("courses").about("List the available courses")) |
11 | 11 | .subcommand( |
12 | | - App::new("download") |
| 12 | + SubCommand::with_name("download") |
13 | 13 | .about("Downloads course exercises") |
14 | 14 | .arg( |
15 | | - Arg::new("course") |
16 | | - .short('c') |
| 15 | + Arg::with_name("course") |
| 16 | + .short("c") |
17 | 17 | .long("course") |
18 | 18 | .value_name("course name") |
19 | 19 | .required(false), |
20 | 20 | ) |
21 | 21 | .arg( |
22 | | - Arg::new("currentdir") |
23 | | - .short('d') |
| 22 | + Arg::with_name("currentdir") |
| 23 | + .short("d") |
24 | 24 | .long("currentdir") |
25 | 25 | .required(false), |
26 | 26 | ), |
27 | 27 | ) |
28 | 28 | .subcommand( |
29 | | - App::new("exercises") |
| 29 | + SubCommand::with_name("exercises") |
30 | 30 | .about("List the exercises for a specific course") |
31 | | - .arg(Arg::new("course").value_name("course").required(true)), |
| 31 | + .arg(Arg::with_name("course").value_name("course").required(true)), |
32 | 32 | ) |
33 | 33 | .subcommand( |
34 | | - App::new("login") |
| 34 | + SubCommand::with_name("login") |
35 | 35 | .about("Login to TMC server") |
36 | 36 | .arg( |
37 | | - Arg::new("non-interactive") |
38 | | - .short('n') |
39 | | - .about("Initiates the non-interactive mode.") |
| 37 | + Arg::with_name("non-interactive") |
| 38 | + .short("n") |
| 39 | + .help("Initiates the non-interactive mode.") |
40 | 40 | .long("non-interactive"), |
41 | 41 | ), |
42 | 42 | ) |
43 | | - .subcommand(App::new("logout").about("Logout from TMC server")) |
| 43 | + .subcommand(SubCommand::with_name("logout").about("Logout from TMC server")) |
44 | 44 | .subcommand( |
45 | | - App::new("organization") |
| 45 | + SubCommand::with_name("organization") |
46 | 46 | .about("Change organization") |
47 | 47 | .arg( |
48 | | - Arg::new("non-interactive") |
49 | | - .short('n') |
50 | | - .about("Initiates the non-interactive mode.") |
| 48 | + Arg::with_name("non-interactive") |
| 49 | + .short("n") |
| 50 | + .help("Initiates the non-interactive mode.") |
51 | 51 | .long("non-interactive"), |
52 | 52 | ), |
53 | 53 | ) |
54 | 54 | .subcommand( |
55 | | - App::new("paste") |
| 55 | + SubCommand::with_name("paste") |
56 | 56 | .about("Submit exercise to TMC pastebin") |
57 | 57 | .arg( |
58 | | - Arg::new("exercise") |
| 58 | + Arg::with_name("exercise") |
59 | 59 | .value_name("exercise") |
60 | 60 | .required(false), |
61 | 61 | ), |
62 | 62 | ) |
63 | 63 | .subcommand( |
64 | | - App::new("submit") |
| 64 | + SubCommand::with_name("submit") |
65 | 65 | .about("Submit exercises to TMC server") |
66 | 66 | .arg( |
67 | | - Arg::new("exercise") |
| 67 | + Arg::with_name("exercise") |
68 | 68 | .value_name("exercise") |
69 | 69 | .required(false), |
70 | 70 | ), |
71 | 71 | ) |
72 | 72 | .subcommand( |
73 | | - App::new("test") |
| 73 | + SubCommand::with_name("test") |
74 | 74 | .about("Run local exercise tests") |
75 | 75 | .arg( |
76 | | - Arg::new("exercise") |
| 76 | + Arg::with_name("exercise") |
77 | 77 | .value_name("exercise") |
78 | 78 | .required(false), |
79 | 79 | ), |
80 | 80 | ) |
81 | 81 | .subcommand( |
82 | | - App::new("fetchupdate") |
| 82 | + SubCommand::with_name("fetchupdate") |
83 | 83 | .setting(AppSettings::Hidden) |
84 | 84 | .about("Finishes the autoupdater. Administator rights needed."), |
85 | 85 | ) |
86 | 86 | .subcommand( |
87 | | - App::new("cleartemp") |
| 87 | + SubCommand::with_name("cleartemp") |
88 | 88 | .setting(AppSettings::Hidden) |
89 | 89 | .about("Removes tempfiles. Administator rights needed."), |
90 | 90 | ) |
91 | 91 | .subcommand( |
92 | | - App::new("elevateddownload") |
| 92 | + SubCommand::with_name("elevateddownload") |
93 | 93 | .setting(AppSettings::Hidden) |
94 | 94 | .about("Downloads course from the tempfile. Administator rights needed."), |
95 | 95 | ) |
96 | | - .subcommand(App::new("update").about("Update exercises")) |
| 96 | + .subcommand(SubCommand::with_name("update").about("Update exercises")) |
97 | 97 | .arg( |
98 | | - Arg::new("no-update") |
99 | | - .short('d') |
| 98 | + Arg::with_name("no-update") |
| 99 | + .short("d") |
100 | 100 | .long("no-update") |
101 | | - .about("Disable auto update temporarily"), |
| 101 | + .help("Disable auto update temporarily"), |
102 | 102 | ) |
103 | 103 | .arg( |
104 | | - Arg::new("testmode") |
| 104 | + Arg::with_name("testmode") |
105 | 105 | .long("testmode") |
106 | | - .about("Only for internal testing, disables server connection"), |
| 106 | + .help("Only for internal testing, disables server connection"), |
107 | 107 | ) |
108 | 108 | } |
0 commit comments