Skip to content

Commit b01ad06

Browse files
author
HoolaBoola
committed
Upgraded clap to v3 for autocompletions
1 parent 2c7b69e commit b01ad06

5 files changed

Lines changed: 143 additions & 119 deletions

File tree

Cargo.lock

Lines changed: 63 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ license = "Apache-2.0"
1313

1414
[dependencies]
1515
url = "2.2.1"
16-
clap = "2.3.3"
16+
clap = "3.0.0-beta.2"
1717
assert_cmd = "0.10"
1818
predicates = "1"
1919
anyhow = "1"

src/cli.rs

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,108 @@
1-
use clap::{App, AppSettings, Arg, SubCommand};
1+
use clap::{App, AppSettings, Arg};
22

33
const PKG_VERSION: Option<&'static str> = option_env!("CARGO_PKG_VERSION");
44

5-
pub fn build_cli() -> App<'static, 'static> {
5+
pub fn build_cli() -> App<'static> {
66
App::new("Test My Code client written in Rust")
77
.setting(AppSettings::ArgRequiredElseHelp)
88
.version(PKG_VERSION.unwrap())
99
.about("Client for downloading, testing and submitting exercises through the Test My Code system")
10-
.subcommand(SubCommand::with_name("courses").about("List the available courses"))
10+
.subcommand(App::new("courses").about("List the available courses"))
1111
.subcommand(
12-
SubCommand::with_name("download")
12+
App::new("download")
1313
.about("Downloads course exercises")
1414
.arg(
15-
Arg::with_name("course")
16-
.short("c")
15+
Arg::new("course")
16+
.short('c')
1717
.long("course")
1818
.value_name("course name")
1919
.required(false),
2020
)
2121
.arg(
22-
Arg::with_name("currentdir")
23-
.short("d")
22+
Arg::new("currentdir")
23+
.short('d')
2424
.long("currentdir")
2525
.required(false),
2626
),
2727
)
2828
.subcommand(
29-
SubCommand::with_name("exercises")
29+
App::new("exercises")
3030
.about("List the exercises for a specific course")
31-
.arg(Arg::with_name("course").value_name("course").required(true)),
31+
.arg(Arg::new("course").value_name("course").required(true)),
3232
)
3333
.subcommand(
34-
SubCommand::with_name("login")
34+
App::new("login")
3535
.about("Login to TMC server")
3636
.arg(
37-
Arg::with_name("non-interactive")
38-
.short("n")
39-
.help("Initiates the non-interactive mode.")
37+
Arg::new("non-interactive")
38+
.short('n')
39+
.about("Initiates the non-interactive mode.")
4040
.long("non-interactive"),
4141
),
4242
)
43-
.subcommand(SubCommand::with_name("logout").about("Logout from TMC server"))
43+
.subcommand(App::new("logout").about("Logout from TMC server"))
4444
.subcommand(
45-
SubCommand::with_name("organization")
45+
App::new("organization")
4646
.about("Change organization")
4747
.arg(
48-
Arg::with_name("non-interactive")
49-
.short("n")
50-
.help("Initiates the non-interactive mode.")
48+
Arg::new("non-interactive")
49+
.short('n')
50+
.about("Initiates the non-interactive mode.")
5151
.long("non-interactive"),
5252
),
5353
)
5454
.subcommand(
55-
SubCommand::with_name("paste")
55+
App::new("paste")
5656
.about("Submit exercise to TMC pastebin")
5757
.arg(
58-
Arg::with_name("exercise")
58+
Arg::new("exercise")
5959
.value_name("exercise")
6060
.required(false),
6161
),
6262
)
6363
.subcommand(
64-
SubCommand::with_name("submit")
64+
App::new("submit")
6565
.about("Submit exercises to TMC server")
6666
.arg(
67-
Arg::with_name("exercise")
67+
Arg::new("exercise")
6868
.value_name("exercise")
6969
.required(false),
7070
),
7171
)
7272
.subcommand(
73-
SubCommand::with_name("test")
73+
App::new("test")
7474
.about("Run local exercise tests")
7575
.arg(
76-
Arg::with_name("exercise")
76+
Arg::new("exercise")
7777
.value_name("exercise")
7878
.required(false),
7979
),
8080
)
8181
.subcommand(
82-
SubCommand::with_name("fetchupdate")
82+
App::new("fetchupdate")
8383
.setting(AppSettings::Hidden)
8484
.about("Finishes the autoupdater. Administator rights needed."),
8585
)
8686
.subcommand(
87-
SubCommand::with_name("cleartemp")
87+
App::new("cleartemp")
8888
.setting(AppSettings::Hidden)
8989
.about("Removes tempfiles. Administator rights needed."),
9090
)
9191
.subcommand(
92-
SubCommand::with_name("elevateddownload")
92+
App::new("elevateddownload")
9393
.setting(AppSettings::Hidden)
9494
.about("Downloads course from the tempfile. Administator rights needed."),
9595
)
96-
.subcommand(SubCommand::with_name("update").about("Update exercises"))
96+
.subcommand(App::new("update").about("Update exercises"))
9797
.arg(
98-
Arg::with_name("no-update")
99-
.short("d")
98+
Arg::new("no-update")
99+
.short('d')
100100
.long("no-update")
101-
.help("Disable auto update temporarily"),
101+
.about("Disable auto update temporarily"),
102102
)
103103
.arg(
104-
Arg::with_name("testmode")
104+
Arg::new("testmode")
105105
.long("testmode")
106-
.help("Only for internal testing, disables server connection"),
106+
.about("Only for internal testing, disables server connection"),
107107
)
108-
109108
}

0 commit comments

Comments
 (0)