File tree Expand file tree Collapse file tree 4 files changed +29
-1
lines changed Expand file tree Collapse file tree 4 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -254,6 +254,14 @@ pub fn create_app() -> App<'static, 'static> {
254254 . required ( true )
255255 . takes_value ( true ) ) )
256256
257+ . subcommand ( SubCommand :: with_name ( "get-course-settings" )
258+ . about ( "Get course settings." )
259+ . arg ( Arg :: with_name ( "course-id" )
260+ . help ( "The ID of the course." )
261+ . long ( "course-id" )
262+ . required ( true )
263+ . takes_value ( true ) ) )
264+
257265 . subcommand ( SubCommand :: with_name ( "paste" )
258266 . about ( "Send exercise to pastebin with comment." )
259267 . arg ( Arg :: with_name ( "submission-url" )
Original file line number Diff line number Diff line change @@ -656,6 +656,19 @@ fn run() -> Result<()> {
656656 data : Some ( courses) ,
657657 } ;
658658 print_output ( & output) ?;
659+ } else if let Some ( matches) = matches. subcommand_matches ( "get-course-settings" ) {
660+ let course_id = matches. value_of ( "course-id" ) . unwrap ( ) ;
661+ let course_id = into_usize ( course_id) ?;
662+ let course = core. get_course ( course_id) . context ( "Failed to get course" ) ?;
663+
664+ let output = Output {
665+ status : Status :: Successful ,
666+ message : None ,
667+ result : OutputResult :: RetrievedData ,
668+ percent_done : 1.0 ,
669+ data : Some ( course) ,
670+ } ;
671+ print_output ( & output) ?;
659672 } else if let Some ( matches) = matches. subcommand_matches ( "paste" ) {
660673 let submission_url = matches. value_of ( "submission-url" ) . unwrap ( ) ;
661674 let submission_url = into_url ( submission_url) ?;
Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ pub struct Course {
8787 pub spyware_urls : Vec < String > ,
8888}
8989
90- #[ derive( Debug , Deserialize ) ]
90+ #[ derive( Debug , Deserialize , Serialize ) ]
9191pub struct CourseData {
9292 pub name : String ,
9393 //pub hide_after
Original file line number Diff line number Diff line change @@ -327,6 +327,13 @@ impl TmcCore {
327327 self . organization_courses ( organization_slug)
328328 }
329329
330+ pub fn get_course ( & self , course_id : usize ) -> Result < CourseData > {
331+ if self . token . is_none ( ) {
332+ return Err ( CoreError :: AuthRequired ) ;
333+ }
334+ self . course ( course_id)
335+ }
336+
330337 /// Sends the given submission as a paste.
331338 ///
332339 /// # Errors
You can’t perform that action at this time.
0 commit comments