Skip to content

Commit cc28eeb

Browse files
committed
Add tabular output with --format flag
Tabular output is much easier to quickly scan for value, as well as being more amenable to traditional UNIX scripting. For example, compare finding the block_size for an image in the following output: $ oxide image list --format=json [ { "block_size": 512, "description": "Debian 13 generic cloud image", "id": "3672f476-51ff-49ab-bd2c-723151a921c6", "name": "debian-13", "os": "Debian", "size": 3221225472, "time_created": "2025-08-11T16:48:17.827861Z", "time_modified": "2025-08-11T16:52:23.411189Z", "version": "13" }, { "block_size": 4096, "description": "Silo image for Packer acceptance testing.", "id": "f13b140e-4d34-4060-b898-6316cdcc2f1e", "name": "packer-acc-test-silo-image", "os": "", "size": 1073741824, "time_created": "2025-05-15T23:11:14.015948Z", "time_modified": "2025-05-15T23:12:02.098119Z", "version": "" } ] Versus: $ oxide image list --format=table:name,block_size NAME BLOCK_SIZE debian-13 512 packer-acc-test-silo-image 4096 For response types that are amenable to tabular formatting, we add a `--format` flag to the subcommand. This takes an optional comma-separated list of field names to print, as larger response items can easily overflow typical terminal widths. The available field names are listed in the `--help` output for the subcommand. Not all API return values can be reasonably formatted as a table. Endpoints returning `()`, byte streams, and unstructured `serde_json::Value` objects are deliberately excluded. Internally, this is implemented using the newly added `ResponseFields` trait, which xtask creates as part of the generated CLI. This enables getting the field names of a type and accessing them as a `serde_json::Value` via their name.
1 parent 9d20b55 commit cc28eeb

19 files changed

+12454
-65
lines changed

Cargo.lock

Lines changed: 23 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ chrono = { version = "0.4.42", features = ["serde"] }
2222
clap = { version = "4.5.47", features = ["derive", "string", "env", "wrap_help"] }
2323
clap_complete = "4.5.57"
2424
colored = "3.0.0"
25+
comfy-table = "7.2.1"
2526
crossterm = { version = "0.29.0", features = [ "event-stream" ] }
2627
dialoguer = "0.11.0"
2728
dirs = "6.0.0"
@@ -32,6 +33,7 @@ flume = "0.11.1"
3233
futures = "0.3.31"
3334
httpmock = "0.7.0"
3435
humantime = "2.3.0"
36+
indexmap = "2.11.3"
3537
indicatif = "0.18.0"
3638
libc = "0.2.175"
3739
log = "0.4.28"
@@ -44,9 +46,11 @@ oxide-httpmock = { path = "sdk-httpmock", version = "0.13.0" }
4446
oxnet = "0.1.3"
4547
predicates = "3.1.3"
4648
pretty_assertions = "1.4.1"
49+
proc-macro2 = "1.0.101"
4750
progenitor = { git = "https://github.com/oxidecomputer/progenitor", default-features = false }
4851
progenitor-client = "0.11.0"
4952
rand = "0.9.2"
53+
quote = "1.0.40"
5054
ratatui = "0.29.0"
5155
rcgen = { version = "0.14.4", features = ["pem"] }
5256
regex = "1.11.2"
@@ -59,6 +63,7 @@ serde = { version = "1.0.219", features = ["derive"] }
5963
serde_json = "1.0.145"
6064
similar = "2.7.0"
6165
support-bundle-viewer = "0.1.2"
66+
syn = "2.0.106"
6267
tabwriter = "1.4.1"
6368
thiserror = "2.0.16"
6469
tempfile = "3.22.0"

cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ chrono = { workspace = true }
2727
clap = { workspace = true }
2828
clap_complete = { workspace = true }
2929
colored = { workspace = true }
30+
comfy-table = { workspace = true }
3031
crossterm = { workspace = true }
3132
dialoguer = { workspace = true }
3233
dirs = { workspace = true }

0 commit comments

Comments
 (0)