@@ -582,7 +582,11 @@ enum Commands {
582582
583583 /// Show gateway status and information.
584584 #[ command( help_template = LEAF_HELP_TEMPLATE , next_help_heading = "FLAGS" ) ]
585- Status ,
585+ Status {
586+ /// Output format.
587+ #[ arg( short = 'o' , long = "output" , value_enum, default_value_t = OutputFormat :: Table ) ]
588+ output : OutputFormat ,
589+ } ,
586590
587591 /// Manage inference configuration.
588592 #[ command( after_help = INFERENCE_EXAMPLES , help_template = SUBCOMMAND_HELP_TEMPLATE ) ]
@@ -1434,6 +1438,10 @@ enum SandboxCommands {
14341438 #[ arg( long, value_parser = [ "manual" , "auto" ] , default_value = "manual" ) ]
14351439 approval_mode : String ,
14361440
1441+ /// Output format.
1442+ #[ arg( short = 'o' , long = "output" , value_enum, default_value_t = OutputFormat :: Table , conflicts_with_all = [ "editor" , "command" , "no_keep" , "forward" ] ) ]
1443+ output : OutputFormat ,
1444+
14371445 /// Command to run after "--" (defaults to an interactive shell).
14381446 #[ arg( last = true , allow_hyphen_values = true ) ]
14391447 command : Vec < String > ,
@@ -1447,8 +1455,12 @@ enum SandboxCommands {
14471455 name : Option < String > ,
14481456
14491457 /// Print only the active policy YAML (same policy as the default view; stdout only).
1450- #[ arg( long) ]
1458+ #[ arg( long, conflicts_with = "output" ) ]
14511459 policy_only : bool ,
1460+
1461+ /// Output format.
1462+ #[ arg( short = 'o' , long = "output" , value_enum, default_value_t = OutputFormat :: Table ) ]
1463+ output : OutputFormat ,
14521464 } ,
14531465
14541466 /// List sandboxes.
@@ -2270,11 +2282,24 @@ async fn main() -> Result<()> {
22702282 // -----------------------------------------------------------
22712283 // Top-level status
22722284 // -----------------------------------------------------------
2273- Some ( Commands :: Status ) => {
2285+ Some ( Commands :: Status { output } ) => {
22742286 if let Ok ( ctx) = resolve_gateway ( & cli. gateway , & cli. gateway_endpoint ) {
22752287 let mut tls = tls. with_gateway_name ( & ctx. name ) ;
22762288 let auth_error = apply_auth_with_status ( & mut tls, & ctx. name ) ;
2277- run:: gateway_status ( & ctx. name , & ctx. endpoint , & tls, auth_error. as_deref ( ) ) . await ?;
2289+ run:: gateway_status (
2290+ & ctx. name ,
2291+ & ctx. endpoint ,
2292+ output. as_str ( ) ,
2293+ & tls,
2294+ auth_error. as_deref ( ) ,
2295+ )
2296+ . await ?;
2297+ } else if openshell_cli:: output:: print_output_single (
2298+ output. as_str ( ) ,
2299+ & ( ) ,
2300+ |( ) | serde_json:: json!( { "status" : "not_configured" } ) ,
2301+ ) ? {
2302+ // Structured output handled.
22782303 } else {
22792304 println ! ( "{}" , "Gateway Status" . cyan( ) . bold( ) ) ;
22802305 println ! ( ) ;
@@ -2885,6 +2910,7 @@ async fn main() -> Result<()> {
28852910 labels,
28862911 envs,
28872912 approval_mode,
2913+ output,
28882914 command,
28892915 } => {
28902916 // Resolve --tty / --no-tty into an Option<bool> override.
@@ -2971,6 +2997,7 @@ async fn main() -> Result<()> {
29712997 labels : labels_map,
29722998 environment : env_map,
29732999 approval_mode : & approval_mode,
3000+ output : output. as_str ( ) ,
29743001 } ,
29753002 & cli. workspace ,
29763003 & tls,
@@ -3030,10 +3057,21 @@ async fn main() -> Result<()> {
30303057 | SandboxCommands :: Download { .. } => {
30313058 unreachable ! ( )
30323059 }
3033- SandboxCommands :: Get { name, policy_only } => {
3060+ SandboxCommands :: Get {
3061+ name,
3062+ policy_only,
3063+ output,
3064+ } => {
30343065 let name = resolve_sandbox_name ( name, & ctx. name , & cli. workspace ) ?;
3035- run:: sandbox_get ( endpoint, & name, policy_only, & cli. workspace , & tls)
3036- . await ?;
3066+ run:: sandbox_get (
3067+ endpoint,
3068+ & name,
3069+ policy_only,
3070+ output. as_str ( ) ,
3071+ & cli. workspace ,
3072+ & tls,
3073+ )
3074+ . await ?;
30373075 }
30383076 SandboxCommands :: List {
30393077 limit,
@@ -3883,7 +3921,7 @@ mod tests {
38833921 . expect ( "global gateway flag should parse with subcommands" ) ;
38843922
38853923 assert_eq ! ( cli. gateway. as_deref( ) , Some ( "demo" ) ) ;
3886- assert ! ( matches!( cli. command, Some ( Commands :: Status ) ) ) ;
3924+ assert ! ( matches!( cli. command, Some ( Commands :: Status { .. } ) ) ) ;
38873925 }
38883926
38893927 #[ test]
@@ -5025,6 +5063,25 @@ mod tests {
50255063 ) ;
50265064 }
50275065
5066+ #[ test]
5067+ fn sandbox_create_output_conflicts_with_side_effect_args ( ) {
5068+ for ( label, extra_args) in [
5069+ ( "--editor" , & [ "--editor" , "code" ] [ ..] ) ,
5070+ ( "trailing command" , & [ "--" , "claude" ] [ ..] ) ,
5071+ ( "--no-keep" , & [ "--no-keep" ] [ ..] ) ,
5072+ ( "--forward" , & [ "--forward" , "8080" ] [ ..] ) ,
5073+ ] {
5074+ let args = [ "openshell" , "sandbox" , "create" , "--output" , "json" ]
5075+ . into_iter ( )
5076+ . chain ( extra_args. iter ( ) . copied ( ) ) ;
5077+ let result = Cli :: try_parse_from ( args) ;
5078+ assert ! (
5079+ result. is_err( ) ,
5080+ "structured output should conflict with {label}"
5081+ ) ;
5082+ }
5083+ }
5084+
50285085 #[ test]
50295086 fn sandbox_create_resource_flags_parse ( ) {
50305087 let cli = Cli :: try_parse_from ( [
0 commit comments