Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 32 additions & 7 deletions crates/openshell-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,11 @@ enum Commands {

/// Show gateway status and information.
#[command(help_template = LEAF_HELP_TEMPLATE, next_help_heading = "FLAGS")]
Status,
Status {
/// Output format.
#[arg(short = 'o', long = "output", value_enum, default_value_t = OutputFormat::Table)]
output: OutputFormat,
},

/// Manage inference configuration.
#[command(after_help = INFERENCE_EXAMPLES, help_template = SUBCOMMAND_HELP_TEMPLATE)]
Expand Down Expand Up @@ -1336,6 +1340,10 @@ enum SandboxCommands {
#[arg(long, value_parser = ["manual", "auto"], default_value = "manual")]
approval_mode: String,

/// Output format.
#[arg(short = 'o', long = "output", value_enum, default_value_t = OutputFormat::Table, conflicts_with_all = ["editor", "command"])]
output: OutputFormat,

/// Command to run after "--" (defaults to an interactive shell).
#[arg(last = true, allow_hyphen_values = true)]
command: Vec<String>,
Expand All @@ -1349,8 +1357,12 @@ enum SandboxCommands {
name: Option<String>,

/// Print only the active policy YAML (same policy as the default view; stdout only).
#[arg(long)]
#[arg(long, conflicts_with = "output")]
policy_only: bool,

/// Output format.
#[arg(short = 'o', long = "output", value_enum, default_value_t = OutputFormat::Table)]
output: OutputFormat,
},

/// List sandboxes.
Expand Down Expand Up @@ -2079,11 +2091,17 @@ async fn main() -> Result<()> {
// -----------------------------------------------------------
// Top-level status
// -----------------------------------------------------------
Some(Commands::Status) => {
Some(Commands::Status { output }) => {
if let Ok(ctx) = resolve_gateway(&cli.gateway, &cli.gateway_endpoint) {
let mut tls = tls.with_gateway_name(&ctx.name);
apply_auth(&mut tls, &ctx.name);
run::gateway_status(&ctx.name, &ctx.endpoint, &tls).await?;
run::gateway_status(&ctx.name, &ctx.endpoint, output.as_str(), &tls).await?;
} else if openshell_cli::output::print_output_single(
output.as_str(),
&(),
|()| serde_json::json!({"status": "not_configured"}),
)? {
// Structured output handled.
} else {
println!("{}", "Gateway Status".cyan().bold());
println!();
Expand Down Expand Up @@ -2612,6 +2630,7 @@ async fn main() -> Result<()> {
labels,
envs,
approval_mode,
output,
command,
} => {
// Resolve --tty / --no-tty into an Option<bool> override.
Expand Down Expand Up @@ -2697,6 +2716,7 @@ async fn main() -> Result<()> {
&labels_map,
&env_map,
&approval_mode,
output.as_str(),
&tls,
))
.await?;
Expand Down Expand Up @@ -2769,9 +2789,14 @@ async fn main() -> Result<()> {
| SandboxCommands::Download { .. } => {
unreachable!()
}
SandboxCommands::Get { name, policy_only } => {
SandboxCommands::Get {
name,
policy_only,
output,
} => {
let name = resolve_sandbox_name(name, &ctx.name)?;
run::sandbox_get(endpoint, &name, policy_only, &tls).await?;
run::sandbox_get(endpoint, &name, policy_only, output.as_str(), &tls)
.await?;
}
SandboxCommands::List {
limit,
Expand Down Expand Up @@ -3455,7 +3480,7 @@ mod tests {
.expect("global gateway flag should parse with subcommands");

assert_eq!(cli.gateway.as_deref(), Some("demo"));
assert!(matches!(cli.command, Some(Commands::Status)));
assert!(matches!(cli.command, Some(Commands::Status { .. })));
}

#[test]
Expand Down
Loading
Loading