Skip to content

Commit 0dd9137

Browse files
committed
Comment on how table formatting works
1 parent f7eb719 commit 0dd9137

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

cli/src/oxide_override.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,29 @@ pub enum OxideOverride {
2828
Table { table: Box<Mutex<TableFormatter>> },
2929
}
3030

31+
/// Format response values into a table.
32+
///
33+
/// This works as follows:
34+
///
35+
/// 1. Get the `schemars` schema of the endpoint's return type. For the endpoints we support
36+
/// tabular output for, this will always be a JSON object.
37+
///
38+
/// 2. Parse the schema and determine the parameters of the object being returned. The column
39+
/// names displayed will be the parameters of the return object.
40+
///
41+
/// 3. Handle different return types:
42+
/// - **Non-paginated scalar objects**: Use directly.
43+
/// - **Non-paginated array object**: Extract the inner type of the array.
44+
/// - **Paginated output**: Extract the inner type of the collection.
45+
/// - **Enums**: Take the union of parameter names across all variants. Fields not present
46+
/// for a given variant will be blank.
47+
///
48+
/// 4. Apply field filtering if requested by the user. Take the intersection of their list
49+
/// and the available fields.
50+
///
51+
/// 5. Format values for display:
52+
/// - Non-scalar objects are printed as compact JSON.
53+
/// - Strings without any spaces have their quotes stripped.
3154
pub struct TableFormatter {
3255
requested_fields: Vec<String>,
3356
fields_to_print: Vec<String>,

0 commit comments

Comments
 (0)