Commit 9ef7b5d
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- cli
- docs
- src
- tests
- data
- xtask
- src
13 files changed
+2663
-55
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
| 44 | + | |
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| |||
0 commit comments