Skip to content

Commit b9b4af7

Browse files
committed
added progress type
1 parent ef345b8 commit b9b4af7

File tree

1 file changed

+32
-16
lines changed

1 file changed

+32
-16
lines changed

tmc-langs/src/lib.rs

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,10 @@ pub fn download_or_update_course_exercises(
161161

162162
let exercises_details = client.get_exercises_details(exercises)?;
163163
let exercises_len = exercises_details.len();
164-
start_stage(
164+
progress_reporter::start_stage::<()>(
165165
exercises_len * 2 + 1, // each download progresses at 2 points, plus the final finishing step
166166
format!("Downloading {} exercises", exercises_len),
167+
None,
167168
);
168169

169170
let mut projects_config = ProjectsConfig::load(projects_dir)?;
@@ -271,11 +272,17 @@ pub fn download_or_update_course_exercises(
271272
DownloadTarget::Template { ref target, .. } => target,
272273
DownloadTarget::Submission { ref target, .. } => target,
273274
};
274-
progress_stage(format!(
275-
"Downloading exercise {} to '{}'",
276-
target_exercise.id,
277-
target_exercise.path.display(),
278-
));
275+
progress_reporter::progress_stage::<ClientUpdateData>(
276+
format!(
277+
"Downloading exercise {} to '{}'",
278+
target_exercise.id,
279+
target_exercise.path.display(),
280+
),
281+
Some(ClientUpdateData::ExerciseDownload {
282+
id: target_exercise.id,
283+
path: target_exercise.path.clone(),
284+
}),
285+
);
279286

280287
match &download_target {
281288
DownloadTarget::Template { target, .. } => {
@@ -305,11 +312,17 @@ pub fn download_or_update_course_exercises(
305312
}
306313
}
307314

308-
progress_stage(format!(
309-
"Downloaded exercise {} to '{}'",
310-
target_exercise.id,
311-
target_exercise.path.display(),
312-
));
315+
progress_reporter::progress_stage::<ClientUpdateData>(
316+
format!(
317+
"Downloaded exercise {} to '{}'",
318+
target_exercise.id,
319+
target_exercise.path.display(),
320+
),
321+
Some(ClientUpdateData::ExerciseDownload {
322+
id: target_exercise.id,
323+
path: target_exercise.path.clone(),
324+
}),
325+
);
313326

314327
Ok(())
315328
}();
@@ -378,11 +391,14 @@ pub fn download_or_update_course_exercises(
378391
};
379392
}
380393

381-
finish_stage(format!(
382-
"Successfully downloaded {} out of {} exercises.",
383-
successful.len(),
384-
exercises_len
385-
));
394+
progress_reporter::finish_stage::<ClientUpdateData>(
395+
format!(
396+
"Successfully downloaded {} out of {} exercises.",
397+
successful.len(),
398+
exercises_len
399+
),
400+
None,
401+
);
386402

387403
let downloaded = successful
388404
.into_iter()

0 commit comments

Comments
 (0)