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
7 changes: 6 additions & 1 deletion crates/cli/src/commands/sbx/image/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(());
Expand Down
10 changes: 8 additions & 2 deletions crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down
Loading