11use clap:: { AppSettings , Arg , Command } ;
22
3- const PKG_VERSION : Option < & ' static str > = option_env ! ( "CARGO_PKG_VERSION" ) ;
4-
53pub fn build_cli ( ) -> Command < ' static > {
6- Command :: new ( "Test My Code client written in Rust" )
4+ Command :: new ( env ! ( "CARGO_PKG_NAME" ) )
5+ . version ( env ! ( "CARGO_PKG_VERSION" ) )
6+ . about ( env ! ( "CARGO_PKG_DESCRIPTION" ) )
77 . arg_required_else_help ( true )
8- . version ( PKG_VERSION . unwrap ( ) )
9- . about ( "Client for downloading, testing and submitting exercises through the Test My Code system" )
108 . subcommand ( Command :: new ( "courses" ) . about ( "List the available courses" ) )
119 . subcommand (
1210 Command :: new ( "download" )
13- . about ( "Downloads course exercises" )
14- . arg (
15- Arg :: new ( "course" )
16- . short ( 'c' )
17- . long ( "course" )
18- . value_name ( "course name" )
19- . required ( false ) ,
11+ . about ( "Downloads course exercises" )
12+ . arg (
13+ Arg :: new ( "course" )
14+ . short ( 'c' )
15+ . long ( "course" )
16+ . value_name ( "course name" )
17+ . required ( false ) ,
2018 )
21- . arg (
22- Arg :: new ( "currentdir" )
23- . short ( 'd' )
24- . long ( "currentdir" )
25- . required ( false ) ,
19+ . arg (
20+ Arg :: new ( "currentdir" )
21+ . short ( 'd' )
22+ . long ( "currentdir" )
23+ . required ( false ) ,
2624 ) ,
27- )
25+ )
2826 . subcommand (
2927 Command :: new ( "exercises" )
30- . about ( "List the exercises for a specific course" )
31- . arg ( Arg :: new ( "course" ) . value_name ( "course" ) . required ( true ) ) ,
32- )
28+ . about ( "List the exercises for a specific course" )
29+ . arg ( Arg :: new ( "course" ) . value_name ( "course" ) . required ( true ) ) ,
30+ )
3331 . subcommand (
34- Command :: new ( "login" )
35- . about ( "Login to TMC server" )
36- . arg (
32+ Command :: new ( "login" ) . about ( "Login to TMC server" ) . arg (
3733 Arg :: new ( "non-interactive" )
38- . short ( 'n' )
39- . help ( "Initiates the non-interactive mode." )
40- . long ( "non-interactive" ) ,
41- ) ,
42- )
34+ . short ( 'n' )
35+ . help ( "Initiates the non-interactive mode." )
36+ . long ( "non-interactive" ) ,
37+ ) ,
38+ )
4339 . subcommand ( Command :: new ( "logout" ) . about ( "Logout from TMC server" ) )
4440 . subcommand (
4541 Command :: new ( "organization" )
46- . about ( "Change organization" )
47- . arg (
48- Arg :: new ( "non-interactive" )
49- . short ( 'n' )
50- . help ( "Initiates the non-interactive mode." )
51- . long ( "non-interactive" ) ,
42+ . about ( "Change organization" )
43+ . arg (
44+ Arg :: new ( "non-interactive" )
45+ . short ( 'n' )
46+ . help ( "Initiates the non-interactive mode." )
47+ . long ( "non-interactive" ) ,
5248 ) ,
53- )
49+ )
5450 . subcommand (
5551 Command :: new ( "paste" )
56- . about ( "Submit exercise to TMC pastebin" )
57- . arg (
58- Arg :: new ( "exercise" )
59- . value_name ( "exercise" )
60- . required ( false ) ,
61- ) ,
62- )
52+ . about ( "Submit exercise to TMC pastebin" )
53+ . arg ( Arg :: new ( "exercise" ) . value_name ( "exercise" ) . required ( false ) ) ,
54+ )
6355 . subcommand (
6456 Command :: new ( "submit" )
65- . about ( "Submit exercises to TMC server" )
66- . arg (
67- Arg :: new ( "exercise" )
68- . value_name ( "exercise" )
69- . required ( false ) ,
70- ) ,
71- )
57+ . about ( "Submit exercises to TMC server" )
58+ . arg ( Arg :: new ( "exercise" ) . value_name ( "exercise" ) . required ( false ) ) ,
59+ )
7260 . subcommand (
7361 Command :: new ( "test" )
74- . about ( "Run local exercise tests" )
75- . arg (
76- Arg :: new ( "exercise" )
77- . value_name ( "exercise" )
78- . required ( false ) ,
79- ) ,
80- )
62+ . about ( "Run local exercise tests" )
63+ . arg ( Arg :: new ( "exercise" ) . value_name ( "exercise" ) . required ( false ) ) ,
64+ )
8165 . subcommand (
8266 Command :: new ( "fetchupdate" )
83- . hide ( true )
84- . about ( "Finishes the autoupdater. Administator rights needed." ) ,
85- )
67+ . hide ( true )
68+ . about ( "Finishes the autoupdater. Administator rights needed." ) ,
69+ )
8670 . subcommand (
8771 Command :: new ( "cleartemp" )
88- . hide ( true )
89- . about ( "Removes tempfiles. Administator rights needed." ) ,
90- )
72+ . hide ( true )
73+ . about ( "Removes tempfiles. Administator rights needed." ) ,
74+ )
9175 . subcommand (
9276 Command :: new ( "elevateddownload" )
9377 . hide ( true )
@@ -111,33 +95,26 @@ pub fn build_cli() -> Command<'static> {
11195 . subcommand ( Command :: new ( "update" ) . about ( "Update exercises" ) )
11296 . arg (
11397 Arg :: new ( "no-update" )
114- . short ( 'd' )
115- . long ( "no-update" )
116- . help ( "Disable auto update temporarily" ) ,
117- )
98+ . short ( 'd' )
99+ . long ( "no-update" )
100+ . help ( "Disable auto update temporarily" ) ,
101+ )
118102 . arg (
119103 Arg :: new ( "testmode" )
120- . long ( "testmode" )
121- . help ( "Only for internal testing, disables server connection" ) ,
122- )
123- . subcommand ( Command :: new ( "generate-completions" )
124- . override_usage ( "tmc generate_completions --[your shell] > /path/to/your/completions/folder" )
125- . about ( "Generate completion scripts for command line usage." )
126- . disable_version_flag ( true )
127- . hide ( true )
128- . setting ( AppSettings :: DeriveDisplayOrder )
129- . arg (
130- Arg :: new ( "bash" )
131- . short ( 'b' )
132- . long ( "bash" ) )
133- . arg (
134- Arg :: new ( "zsh" )
135- . short ( 'z' )
136- . long ( "zsh" )
137- )
138- . arg (
139- Arg :: new ( "powershell" )
140- . short ( 'p' )
141- . long ( "powershell" ) )
142- )
104+ . long ( "testmode" )
105+ . help ( "Only for internal testing, disables server connection" ) ,
106+ )
107+ . subcommand (
108+ Command :: new ( "generate-completions" )
109+ . override_usage (
110+ "tmc generate_completions --[your shell] > /path/to/your/completions/folder" ,
111+ )
112+ . about ( "Generate completion scripts for command line usage." )
113+ . disable_version_flag ( true )
114+ . hide ( true )
115+ . setting ( AppSettings :: DeriveDisplayOrder )
116+ . arg ( Arg :: new ( "bash" ) . short ( 'b' ) . long ( "bash" ) )
117+ . arg ( Arg :: new ( "zsh" ) . short ( 'z' ) . long ( "zsh" ) )
118+ . arg ( Arg :: new ( "powershell" ) . short ( 'p' ) . long ( "powershell" ) ) ,
119+ )
143120}
0 commit comments