mirror of
https://github.com/nushell/nushell.git
synced 2025-08-19 13:15:17 +02:00
add a vertical record view
This commit is contained in:
@@ -56,6 +56,35 @@ impl Command for Table {
|
||||
Ok(Value::Nothing { span: call.head })
|
||||
}
|
||||
}
|
||||
Value::Record { cols, vals, .. } => {
|
||||
let mut output = vec![];
|
||||
|
||||
for (c, v) in cols.into_iter().zip(vals.into_iter()) {
|
||||
output.push(vec![
|
||||
StyledString {
|
||||
contents: c,
|
||||
style: nu_table::TextStyle::default_header(),
|
||||
},
|
||||
StyledString {
|
||||
contents: v.into_string(),
|
||||
style: nu_table::TextStyle::default(),
|
||||
},
|
||||
])
|
||||
}
|
||||
|
||||
let table = nu_table::Table {
|
||||
headers: vec![],
|
||||
data: output,
|
||||
theme: nu_table::Theme::rounded(),
|
||||
};
|
||||
|
||||
let result = nu_table::draw_table(&table, 80, &HashMap::new());
|
||||
|
||||
Ok(Value::String {
|
||||
val: result,
|
||||
span: call.head,
|
||||
})
|
||||
}
|
||||
x => Ok(x),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user