Skip to content

Commit 8b97bbb

Browse files
committed
help to cli args
1 parent 1a0a3b1 commit 8b97bbb

File tree

1 file changed

+56
-12
lines changed

1 file changed

+56
-12
lines changed

tmc-langs-cli/src/main.rs

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,14 @@ fn run() -> Result<()> {
4949
.about(env!("CARGO_PKG_DESCRIPTION"))
5050

5151
.subcommand(SubCommand::with_name("checkstyle")
52-
.about("Run checkstyle or similar plugin to project if applicable.")
52+
.about("Check code style for the exercise.")
5353
.arg(Arg::with_name("exercise-path")
54+
.help("Path to the directory where the project resides.")
5455
.long("exercise-path")
5556
.required(true)
5657
.takes_value(true))
5758
.arg(Arg::with_name("output-path")
59+
.help("Path to the file where the check results will be written. Overwritten if it already exists.")
5860
.long("output-path")
5961
.required(true)
6062
.takes_value(true))
@@ -65,45 +67,53 @@ fn run() -> Result<()> {
6567
.takes_value(true)))
6668

6769
.subcommand(SubCommand::with_name("compress-project")
68-
.about("Compress target project into a ZIP.")
70+
.about("Compress target exercise into a ZIP.")
6971
.arg(Arg::with_name("exercise-path")
72+
.help("Path to the directory where the exercise resides.")
7073
.long("exercise-path")
7174
.required(true)
7275
.takes_value(true))
7376
.arg(Arg::with_name("output-path")
77+
.help("Path to the output archive. Overwritten if it already exists.")
7478
.long("output-path")
7579
.required(true)
7680
.takes_value(true)))
7781

7882
.subcommand(SubCommand::with_name("extract-project")
79-
.about("Given a downloaded zip, extracts to specified folder.")
80-
.arg(Arg::with_name("exercise-path")
81-
.long("exercise-path")
83+
.about("Extract an exercise archive.")
84+
.arg(Arg::with_name("archive-path")
85+
.help("Path to the archive.")
86+
.long("archive-path")
8287
.required(true)
8388
.takes_value(true))
8489
.arg(Arg::with_name("output-path")
90+
.help("Path to the directory where the archive will be extracted.")
8591
.long("output-path")
8692
.required(true)
8793
.takes_value(true)))
8894

8995
.subcommand(SubCommand::with_name("prepare-solutions")
9096
.about("Prepare a presentable solution from the original.")
9197
.arg(Arg::with_name("exercise-path")
98+
.help("Path to the directory where the exercise resides.")
9299
.long("exercise-path")
93100
.required(true)
94101
.takes_value(true))
95102
.arg(Arg::with_name("output-path")
103+
.help("Path to the directory where the processed files will be copied.")
96104
.long("output-path")
97105
.required(true)
98106
.takes_value(true)))
99107

100108
.subcommand(SubCommand::with_name("prepare-stubs")
101109
.about("Prepare a stub exercise from the original.")
102110
.arg(Arg::with_name("exercise-path")
111+
.help("Path to the directory where the exercise resides.")
103112
.long("exercise-path")
104113
.required(true)
105114
.takes_value(true))
106115
.arg(Arg::with_name("output-path")
116+
.help("Path to the directory where the processed files will be copied.")
107117
.long("output-path")
108118
.required(true)
109119
.takes_value(true)))
@@ -114,59 +124,68 @@ fn run() -> Result<()> {
114124
.subcommand(SubCommand::with_name("run-tests")
115125
.about("Run the tests for the exercise.")
116126
.arg(Arg::with_name("exercise-path")
127+
.help("Path to the directory where the exercise resides.")
117128
.long("exercise-path")
118129
.required(true)
119130
.takes_value(true))
120131
.arg(Arg::with_name("output-path")
132+
.help("Path to the file where the test results will be written. Overwritten if it already exists.")
121133
.long("output-path")
122134
.required(true)
123135
.takes_value(true))
124136
.arg(Arg::with_name("checkstyle-output-path")
137+
.help("Runs checkstyle if given. Path to the file where the style results will be written.")
125138
.long("checkstyle-output-path")
126-
.help("Runs checkstyle if defined")
127139
.takes_value(true)
128140
.requires("locale"))
129141
.arg(Arg::with_name("locale")
130-
.help("Language as a three letter ISO 639-3 code, e.g. 'eng' or 'fin'.")
142+
.help("Language as a three letter ISO 639-3 code, e.g. 'eng' or 'fin'. Required if checkstyle-output-path is given.")
131143
.long("locale")
132144
.takes_value(true)))
133145

134146
.subcommand(SubCommand::with_name("scan-exercise")
135147
.about("Produce an exercise description of an exercise directory.")
136148
.arg(Arg::with_name("exercise-path")
149+
.help("Path to the directory where the project resides.")
137150
.long("exercise-path")
138151
.required(true)
139152
.takes_value(true))
140153
.arg(Arg::with_name("output-path")
154+
.help("Path to the file where the scan results will be written. Overwritten if it already exists.")
141155
.long("output-path")
142156
.required(true)
143157
.takes_value(true)))
144158

145159
.subcommand(SubCommand::with_name("find-exercises")
146160
.about("Produce list of found exercises.")
147161
.arg(Arg::with_name("exercise-path")
162+
.help("Path to the directory where the project resides.")
148163
.long("exercise-path")
149164
.required(true)
150165
.takes_value(true))
151166
.arg(Arg::with_name("output-path")
167+
.help("Path to the file where the search results will be written. Overwritten if it already exists.")
152168
.long("output-path")
153169
.required(true)
154170
.takes_value(true)))
155171

156172
.subcommand(SubCommand::with_name("get-exercise-packaging-configuration")
157173
.about("Returns configuration of under which folders student and nonstudent files are located.")
158174
.arg(Arg::with_name("exercise-path")
175+
.help("Path to the directory where the exercise resides.")
159176
.long("exercise-path")
160177
.required(true)
161178
.takes_value(true))
162179
.arg(Arg::with_name("output-path")
180+
.help("Path to the file where the configuration will be written. Overwritten if it already exists.")
163181
.long("output-path")
164182
.required(true)
165183
.takes_value(true)))
166184

167185
.subcommand(SubCommand::with_name("clean")
168186
.about("Clean target directory.")
169187
.arg(Arg::with_name("exercise-path")
188+
.help("Path to the directory where the exercise resides.")
170189
.long("exercise-path")
171190
.required(true)
172191
.takes_value(true)))
@@ -180,9 +199,9 @@ fn run() -> Result<()> {
180199
.takes_value(true))
181200

182201
.subcommand(SubCommand::with_name("login")
183-
.about("Login and store OAuth2 token in config.")
202+
.about("Login and store OAuth2 token in config. You can login either by email and password or an access token.")
184203
.arg(Arg::with_name("email")
185-
.help("The email address of your TMC account")
204+
.help("The email address of your TMC account.")
186205
.long("email")
187206
.takes_value(true)
188207
.required_unless("set-access-token"))
@@ -215,6 +234,7 @@ fn run() -> Result<()> {
215234
.subcommand(SubCommand::with_name("get-course-details")
216235
.about("Get course details.")
217236
.arg(Arg::with_name("course-id")
237+
.help("The ID of the course.")
218238
.long("course-id")
219239
.required(true)
220240
.takes_value(true)))
@@ -230,14 +250,17 @@ fn run() -> Result<()> {
230250
.subcommand(SubCommand::with_name("paste")
231251
.about("Send exercise to pastebin with comment.")
232252
.arg(Arg::with_name("submission-url")
253+
.help("The URL where the submission should be posted.")
233254
.long("submission-url")
234255
.required(true)
235256
.takes_value(true))
236257
.arg(Arg::with_name("submission-path")
258+
.help("Path to the exercise to be submitted.")
237259
.long("submission-path")
238260
.required(true)
239261
.takes_value(true))
240262
.arg(Arg::with_name("paste-message")
263+
.help("Optional message to attach to the paste.")
241264
.long("paste-message")
242265
.takes_value(true))
243266
.arg(Arg::with_name("locale")
@@ -249,6 +272,7 @@ fn run() -> Result<()> {
249272
.subcommand(SubCommand::with_name("run-checkstyle")
250273
.about("Run checkstyle.")
251274
.arg(Arg::with_name("exercise-path")
275+
.help("Path to the directory where the exercise resides.")
252276
.long("exercise-path")
253277
.required(true)
254278
.takes_value(true))
@@ -261,13 +285,15 @@ fn run() -> Result<()> {
261285
.subcommand(SubCommand::with_name("run-tests")
262286
.about("Run tests.")
263287
.arg(Arg::with_name("exercise-path")
288+
.help("Path to the directory where the exercise resides.")
264289
.long("exercise-path")
265290
.required(true)
266291
.takes_value(true)))
267292

268293
.subcommand(SubCommand::with_name("send-feedback")
269294
.about("Send feedback.")
270295
.arg(Arg::with_name("feedback-url")
296+
.help("URL where the feedback should be posted.")
271297
.long("feedback-url")
272298
.required(true)
273299
.takes_value(true))
@@ -283,10 +309,12 @@ fn run() -> Result<()> {
283309
.subcommand(SubCommand::with_name("submit")
284310
.about("Submit exercise.")
285311
.arg(Arg::with_name("submission-url")
312+
.help("URL where the submission should be posted.")
286313
.long("submission-url")
287314
.required(true)
288315
.takes_value(true))
289316
.arg(Arg::with_name("submission-path")
317+
.help("Path to the directory where the exercise resides.")
290318
.long("submission-path")
291319
.required(true)
292320
.takes_value(true))
@@ -298,13 +326,15 @@ fn run() -> Result<()> {
298326
.subcommand(SubCommand::with_name("wait-for-submission")
299327
.about("Wait for a submission to finish.")
300328
.arg(Arg::with_name("submission-url")
329+
.help("URL to the submission's status.")
301330
.long("submission-url")
302331
.required(true)
303332
.takes_value(true)))
304333

305334
.subcommand(SubCommand::with_name("get-exercise-updates")
306335
.about("Get exercise updates.")
307336
.arg(Arg::with_name("course-id")
337+
.help("The ID of the course")
308338
.long("course-id")
309339
.required(true)
310340
.takes_value(true))
@@ -320,28 +350,33 @@ fn run() -> Result<()> {
320350
.subcommand(SubCommand::with_name("mark-review-as-read")
321351
.about("Mark review as read.")
322352
.arg(Arg::with_name("review-update-url")
353+
.help("URL to the review update API.")
323354
.long("review-update-url")
324355
.required(true)
325356
.takes_value(true)))
326357

327358
.subcommand(SubCommand::with_name("get-unread-reviews")
328359
.about("Get unread reviews.")
329360
.arg(Arg::with_name("reviews-url")
361+
.help("URL to the reviews API.")
330362
.long("reviews-url")
331363
.required(true)
332364
.takes_value(true)))
333365

334366
.subcommand(SubCommand::with_name("request-code-review")
335367
.about("Request code review.")
336368
.arg(Arg::with_name("submission-url")
369+
.help("URL where the submission should be posted.")
337370
.long("submission-url")
338371
.required(true)
339372
.takes_value(true))
340373
.arg(Arg::with_name("submission-path")
374+
.help("Path to the directory where the submission resides.")
341375
.long("submission-path")
342376
.required(true)
343377
.takes_value(true))
344378
.arg(Arg::with_name("message-for-reviewer")
379+
.help("Message for the review.")
345380
.long("message-for-reviewer")
346381
.required(true)
347382
.takes_value(true))
@@ -354,41 +389,50 @@ fn run() -> Result<()> {
354389
.subcommand(SubCommand::with_name("download-model-solution")
355390
.about("Download model solutions.")
356391
.arg(Arg::with_name("solution-download-url")
392+
.help("URL to the solution download.")
357393
.long("solution-download-url")
358394
.required(true)
359395
.takes_value(true))
360396
.arg(Arg::with_name("target")
397+
.help("Path to where the model solution will be downloaded.")
361398
.long("target")
362399
.required(true)
363400
.takes_value(true)))
364401

365402
.subcommand(SubCommand::with_name("reset-exercise")
366403
.about("Reset exercise, optionally submitting it before doing so.")
367404
.arg(Arg::with_name("exercise-path")
405+
.help("Path to the directory where the project resides.")
368406
.long("exercise-path")
369407
.required(true)
370408
.takes_value(true))
371409
.arg(Arg::with_name("save-old-state")
410+
.help("If set, the exercise is submitted to the server before resetting it.")
372411
.long("save-old-state")
373412
.requires("submission-url"))
374413
.arg(Arg::with_name("submission-url")
414+
.help("Required if save-old-state is set. The URL where the submission should be posted.")
375415
.long("submission-url")
376416
.takes_value(true)))
377417

378418
.subcommand(SubCommand::with_name("download-old-submission")
379419
.about("Downloads an old submission.")
380420
.arg(Arg::with_name("exercise-id")
421+
.help("The ID of the exercise.")
381422
.long("exercise-id")
382423
.required(true)
383424
.takes_value(true))
384425
.arg(Arg::with_name("output-path")
426+
.help("Path to where the submission should be downloaded.")
385427
.long("exercise-path")
386428
.required(true)
387429
.takes_value(true))
388430
.arg(Arg::with_name("save-old-state")
431+
.help("If set, the exercise is submitted to the server before resetting it.")
389432
.long("save-old-state")
390433
.requires("submission-url"))
391434
.arg(Arg::with_name("submission-url")
435+
.help("Required if save-old-state is set. The URL where the submission should be posted.")
392436
.long("submission-url")
393437
.takes_value(true))))
394438

@@ -427,13 +471,13 @@ fn run() -> Result<()> {
427471
)
428472
})?;
429473
} else if let Some(matches) = matches.subcommand_matches("extract-project") {
430-
let exercise_path = matches.value_of("exercise-path").unwrap();
431-
let exercise_path = Path::new(exercise_path);
474+
let archive_path = matches.value_of("archive-path").unwrap();
475+
let archive_path = Path::new(archive_path);
432476

433477
let output_path = matches.value_of("output-path").unwrap();
434478
let output_path = Path::new(output_path);
435479

436-
task_executor::extract_project(exercise_path, output_path)
480+
task_executor::extract_project(archive_path, output_path)
437481
.with_context(|| format!("Failed to extract project at {}", output_path.display()))?;
438482
} else if let Some(matches) = matches.subcommand_matches("prepare-solutions") {
439483
let exercise_path = matches.value_of("exercise-path").unwrap();

0 commit comments

Comments
 (0)