@@ -531,9 +531,13 @@ enum Commands {
531531 command : Option < GatewayCommands > ,
532532 } ,
533533
534- /// Show gateway status and information.
534+ /// Show live gateway status and runtime information.
535535 #[ command( help_template = LEAF_HELP_TEMPLATE , next_help_heading = "FLAGS" ) ]
536- Status ,
536+ Status {
537+ /// Output format.
538+ #[ arg( short = 'o' , long = "output" , value_enum, default_value_t = OutputFormat :: Table ) ]
539+ output : OutputFormat ,
540+ } ,
537541
538542 /// Manage inference configuration.
539543 #[ command( after_help = INFERENCE_EXAMPLES , help_template = SUBCOMMAND_HELP_TEMPLATE ) ]
@@ -2083,20 +2087,14 @@ async fn main() -> Result<()> {
20832087 // -----------------------------------------------------------
20842088 // Top-level status
20852089 // -----------------------------------------------------------
2086- Some ( Commands :: Status ) => {
2090+ Some ( Commands :: Status { output } ) => {
20872091 if let Ok ( ctx) = resolve_gateway ( & cli. gateway , & cli. gateway_endpoint ) {
20882092 let mut tls = tls. with_gateway_name ( & ctx. name ) ;
20892093 apply_auth ( & mut tls, & ctx. name ) ;
2090- run:: gateway_status ( & ctx. name , & ctx. endpoint , & tls) . await ?;
2094+ run:: gateway_status ( & ctx. name , & ctx. endpoint , & tls, output. as_str ( ) , cli. verbose )
2095+ . await ?;
20912096 } else {
2092- println ! ( "{}" , "Gateway Status" . cyan( ) . bold( ) ) ;
2093- println ! ( ) ;
2094- println ! ( " {} No gateway configured." , "Status:" . dimmed( ) ) ;
2095- println ! ( ) ;
2096- println ! (
2097- "Register a gateway with: {}" ,
2098- "openshell gateway add <endpoint>" . dimmed( )
2099- ) ;
2097+ run:: gateway_status_not_configured ( output. as_str ( ) ) ?;
21002098 }
21012099 }
21022100
@@ -3463,7 +3461,20 @@ mod tests {
34633461 . expect ( "global gateway flag should parse with subcommands" ) ;
34643462
34653463 assert_eq ! ( cli. gateway. as_deref( ) , Some ( "demo" ) ) ;
3466- assert ! ( matches!( cli. command, Some ( Commands :: Status ) ) ) ;
3464+ assert ! ( matches!( cli. command, Some ( Commands :: Status { .. } ) ) ) ;
3465+ }
3466+
3467+ #[ test]
3468+ fn status_accepts_output_json ( ) {
3469+ let cli = Cli :: try_parse_from ( [ "openshell" , "status" , "-o" , "json" ] )
3470+ . expect ( "status -o json should parse" ) ;
3471+
3472+ assert ! ( matches!(
3473+ cli. command,
3474+ Some ( Commands :: Status {
3475+ output: OutputFormat :: Json
3476+ } )
3477+ ) ) ;
34673478 }
34683479
34693480 #[ test]
0 commit comments