Skip to content

Commit c93a15a

Browse files
committed
fetch-old-submissions
1 parent 0c459df commit c93a15a

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

tmc-langs-cli/src/app.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,14 @@ pub fn create_app() -> App<'static, 'static> {
357357
.help("Set to avoid blocking.")
358358
.long("dont-block")))
359359

360+
.subcommand(SubCommand::with_name("fetch-old-submissions")
361+
.about("Fetch the current user's old submissions for an exercise.")
362+
.arg(Arg::with_name("exercise-id")
363+
.help("The ID of the exercise.")
364+
.long("exercise-id")
365+
.required(true)
366+
.takes_value(true)))
367+
360368
.subcommand(SubCommand::with_name("wait-for-submission")
361369
.about("Wait for a submission to finish.")
362370
.arg(Arg::with_name("submission-url")

tmc-langs-cli/src/main.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,21 @@ fn run() -> Result<()> {
840840
};
841841
print_output(&output)?;
842842
}
843+
} else if let Some(matches) = matches.subcommand_matches("fetch-old-submissions") {
844+
let exercise_id = matches.value_of("exercise-id").unwrap();
845+
let exercise_id = into_usize(exercise_id)?;
846+
let submissions = core
847+
.exercise_submissions(exercise_id)
848+
.context("Failed to get submissions")?;
849+
850+
let output = Output {
851+
status: Status::Successful,
852+
message: None,
853+
result: OutputResult::RetrievedData,
854+
percent_done: 1.0,
855+
data: Some(submissions),
856+
};
857+
print_output(&output)?;
843858
} else if let Some(matches) = matches.subcommand_matches("wait-for-submission") {
844859
let submission_url = matches.value_of("submission-url").unwrap();
845860
let submission_finished = core

tmc-langs-core/src/tmc_core.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,10 @@ impl TmcCore {
488488
self.download_submission(submission_id, target)
489489
}
490490

491+
pub fn exercise_submissions(&self, exercise_id: usize) -> Result<Vec<Submission>> {
492+
self.exercise_submissions_for_current_user(exercise_id)
493+
}
494+
491495
pub fn wait_for_submission(&self, submission_url: &str) -> Result<SubmissionFinished> {
492496
let mut previous_status = None;
493497
loop {

0 commit comments

Comments
 (0)