@@ -10,7 +10,7 @@ use self::config::{CourseConfig, Credentials, Exercise, TmcConfig};
1010use self :: error:: { InvalidTokenError , SandboxTestError } ;
1111use self :: output:: {
1212 CombinedCourseData , DownloadOrUpdateCourseExercise , DownloadOrUpdateCourseExercisesResult ,
13- ErrorData , Kind , Output , OutputData , OutputResult , Status , Warnings ,
13+ ErrorData , Kind , LocalExercise , Output , OutputData , OutputResult , Status , Warnings ,
1414} ;
1515use anyhow:: { Context , Result } ;
1616use clap:: { ArgMatches , Error , ErrorKind } ;
@@ -394,6 +394,36 @@ fn run_app(matches: ArgMatches, pretty: bool, warnings: &mut Vec<anyhow::Error>)
394394 } ) ;
395395 print_output ( & output, pretty, & warnings) ?
396396 }
397+ ( "list-local-course-exercises" , Some ( matches) ) => {
398+ let client_name = matches. value_of ( "client-name" ) . unwrap ( ) ;
399+
400+ let course_slug = matches. value_of ( "course-slug" ) . unwrap ( ) ;
401+
402+ let projects_dir = TmcConfig :: load ( client_name) ?. projects_dir ;
403+ let mut projects_config = ProjectsConfig :: load ( & projects_dir) ?;
404+
405+ let exercises = projects_config
406+ . courses
407+ . remove ( course_slug)
408+ . map ( |cc| cc. exercises )
409+ . unwrap_or_default ( ) ;
410+ let mut local_exercises: Vec < LocalExercise > = vec ! [ ] ;
411+ for ( exercise_slug, _) in exercises {
412+ local_exercises. push ( LocalExercise {
413+ exercise_path : projects_dir. join ( course_slug) . join ( & exercise_slug) ,
414+ exercise_slug,
415+ } )
416+ }
417+
418+ let output = Output :: OutputData ( OutputData {
419+ status : Status :: Finished ,
420+ message : Some ( format ! ( "listed local exercises for {}" , course_slug, ) ) ,
421+ result : OutputResult :: ExecutedCommand ,
422+ percent_done : 1.0 ,
423+ data : Some ( local_exercises) ,
424+ } ) ;
425+ print_output ( & output, pretty, & warnings) ?
426+ }
397427 ( "prepare-solutions" , Some ( matches) ) => {
398428 let exercise_path = matches. value_of ( "exercise-path" ) . unwrap ( ) ;
399429 let exercise_path = Path :: new ( exercise_path) ;
0 commit comments