From 2c507ca562098c4132d0c30452f0e242998c9cb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Salvador=20Giron=C3=A8s?= Date: Tue, 26 May 2026 17:23:22 +0200 Subject: [PATCH] Add hidden --json flag to tl sbx image ls Enables scripted consumers (e.g. the indexify-deployment stress-test image cleanup in tests/build_sandbox_image/build.py) to parse the image list without screen-scraping the comfy_table output. Mirrors the existing hidden --json on `tl sbx image create`. Co-Authored-By: Claude Opus 4.7 (1M context) --- crates/cli/src/commands/sbx/image/ls.rs | 7 ++++++- crates/cli/src/main.rs | 10 ++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/crates/cli/src/commands/sbx/image/ls.rs b/crates/cli/src/commands/sbx/image/ls.rs index 5169964c5..6f4bb667b 100644 --- a/crates/cli/src/commands/sbx/image/ls.rs +++ b/crates/cli/src/commands/sbx/image/ls.rs @@ -4,12 +4,17 @@ use crate::auth::context::CliContext; use crate::error::Result; use crate::output::table::new_table; -pub async fn run(ctx: &CliContext) -> Result<()> { +pub async fn run(ctx: &CliContext, output_json: bool) -> Result<()> { let (base_url, _, _) = super::templates_base_url(ctx)?; let client = ctx.client()?; let items = super::list_all_images(ctx, &client, &base_url).await?; + if output_json { + println!("{}", serde_json::to_string_pretty(&items)?); + return Ok(()); + } + if items.is_empty() { println!("No images found."); return Ok(()); diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index 206925e6d..8918d5d6d 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -653,7 +653,11 @@ enum ImageCommands { }, /// List all sandbox images - Ls, + Ls { + /// Print the sandbox image list as JSON to stdout + #[arg(long = "json", hide = true)] + json: bool, + }, /// Show details for a sandbox image Describe { @@ -1145,7 +1149,9 @@ async fn run_command(ctx: &mut CliContext, command: Commands) -> error::Result<( ) .await } - ImageCommands::Ls => commands::sbx::image::ls::run(ctx).await, + ImageCommands::Ls { json } => { + commands::sbx::image::ls::run(ctx, json).await + } ImageCommands::Describe { name_or_id } => { commands::sbx::image::describe::run(ctx, &name_or_id).await }