Skip to content

Commit 9ef7b5d

Browse files
committed
Add option for tabular output
Currently all commands will display their results as pretty-printed JSON. Tabular output is convenient for easy comparison of a single field when multiple objects are returned, and more amenable to traditional shell processing. Add a new global `--format` flag to control output format, defaulting to the existing JSON output. As larger output items, such as instances, can easily overflow a typical terminal width, we allow users to specify which fields to print with `--format=table:field1,field2,...`. Non-scalar fields within a returned object will be printed in compact JSON format, e.g. `{"cpus":0,"memory":0,"storage":0}` for the `allocated` field on `oxide silo utilization list`. To determine the field names to be shown in the table header, we parse the schema for the return type as part of `OxideOverride`. This logic makes some assumptions about the shape of the data returned, and we need to ensure that it remains valid. Add a new return_types `xtask` job, which writes out all return types from the Oxide API to a file, against which we test the parsing logic.
1 parent 5fce32c commit 9ef7b5d

File tree

13 files changed

+2663
-55
lines changed

13 files changed

+2663
-55
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ chrono = { version = "0.4.41", features = ["serde"] }
2222
clap = { version = "4.5.40", features = ["derive", "string", "env", "wrap_help"] }
2323
clap_complete = "4.5.54"
2424
colored = "3.0.0"
25+
comfy-table = "7.1.4"
2526
crossterm = { version = "0.29.0", features = [ "event-stream" ] }
2627
dialoguer = "0.11.0"
2728
dirs = "6.0.0"
@@ -32,13 +33,15 @@ flume = "0.11.1"
3233
futures = "0.3.31"
3334
httpmock = "0.7.0"
3435
humantime = "2.2.0"
36+
indexmap = "2.10.0"
3537
indicatif = "0.17.12"
3638
libc = "0.2.174"
3739
log = "0.4.26"
3840
md5 = "0.7.0"
3941
newline-converter = "0.3.0"
4042
oauth2 = "5.0.0"
4143
open = "5.3.2"
44+
openapiv3 = "2.2.0"
4245
oxide = { path = "sdk", version = "0.12.0" }
4346
oxide-httpmock = { path = "sdk-httpmock", version = "0.12.0" }
4447
oxnet = "0.1.2"

cli/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ 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 }
3334
env_logger = { workspace = true }
3435
futures = { workspace = true }
3536
humantime = { workspace = true }
37+
indexmap = { workspace = true }
3638
indicatif = { workspace = true }
3739
log = { workspace = true }
3840
md5 = { workspace = true }

0 commit comments

Comments
 (0)