File tree Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -219,6 +219,14 @@ pub fn create_app() -> App<'static, 'static> {
219219 . subcommand ( SubCommand :: with_name ( "get-organizations" )
220220 . about ( "Get organizations." ) )
221221
222+ . subcommand ( SubCommand :: with_name ( "get-organization" )
223+ . about ( "Get organization." )
224+ . arg ( Arg :: with_name ( "organization" )
225+ . help ( "Organization slug (e.g. mooc, hy)." )
226+ . long ( "organization" )
227+ . required ( true )
228+ . takes_value ( true ) ) )
229+
222230 . subcommand ( SubCommand :: with_name ( "download-or-update-exercises" )
223231 . about ( "Download exercise." )
224232 . arg ( Arg :: with_name ( "exercise" )
Original file line number Diff line number Diff line change @@ -591,6 +591,20 @@ fn run() -> Result<()> {
591591 data : Some ( orgs) ,
592592 } ;
593593 print_output ( & output) ?;
594+ } else if let Some ( matches) = matches. subcommand_matches ( "get-organization" ) {
595+ let organization_slug = matches. value_of ( "organization" ) . unwrap ( ) ;
596+ let org = core
597+ . get_organization ( organization_slug)
598+ . context ( "Failed to get organization" ) ?;
599+
600+ let output = Output {
601+ status : Status :: Successful ,
602+ message : None ,
603+ result : OutputResult :: RetrievedData ,
604+ percent_done : 1.0 ,
605+ data : Some ( org) ,
606+ } ;
607+ print_output ( & output) ?;
594608 } else if let Some ( matches) = matches. subcommand_matches ( "download-or-update-exercises" ) {
595609 let mut exercise_args = matches. values_of ( "exercise" ) . unwrap ( ) ;
596610 let mut exercises = vec ! [ ] ;
Original file line number Diff line number Diff line change @@ -229,6 +229,14 @@ impl TmcCore {
229229 self . organizations ( )
230230 }
231231
232+ /// Fetches an organization.
233+ ///
234+ /// # Errors
235+ /// Returns an error if there's some problem reaching the API, or if the API returns an error.
236+ pub fn get_organization ( & self , organization_slug : & str ) -> Result < Organization > {
237+ self . organization ( organization_slug)
238+ }
239+
232240 /// Unimplemented.
233241 #[ deprecated = "unimplemented" ]
234242 pub fn send_diagnostics ( & self ) {
You can’t perform that action at this time.
0 commit comments