mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 14:40:06 +02:00
nu-table/ Add table.indent
configuration (#9983)
Hi there. Am I got it right? ref: https://github.com/zhiburt/tabled/issues/358 cc: @fdncred --------- Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
This commit is contained in:
@ -2560,3 +2560,107 @@ fn theme_cmd(theme: &str, footer: bool, then: &str) -> String {
|
||||
|
||||
format!("$env.config.table.mode = {theme}; $env.config.table.header_on_separator = true; {with_foorter}; {then}")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn table_padding_not_default() {
|
||||
let actual = nu!("$env.config.table.padding = 5; [[a b, c]; [1 2 3] [4 5 [1 2 3]]] | table");
|
||||
assert_eq!(
|
||||
actual.out,
|
||||
"╭───────────┬───────────┬───────────┬────────────────────────╮\
|
||||
│ # │ a │ b │ c │\
|
||||
├───────────┼───────────┼───────────┼────────────────────────┤\
|
||||
│ 0 │ 1 │ 2 │ 3 │\
|
||||
│ 1 │ 4 │ 5 │ [list 3 items] │\
|
||||
╰───────────┴───────────┴───────────┴────────────────────────╯"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn table_padding_zero() {
|
||||
let actual = nu!(
|
||||
"$env.config.table.padding = {left: 0, right: 0}; [[a b, c]; [1 2 3] [4 5 [1 2 3]]] | table"
|
||||
);
|
||||
assert_eq!(
|
||||
actual.out,
|
||||
"╭─┬─┬─┬──────────────╮\
|
||||
│#│a│b│ c │\
|
||||
├─┼─┼─┼──────────────┤\
|
||||
│0│1│2│ 3│\
|
||||
│1│4│5│[list 3 items]│\
|
||||
╰─┴─┴─┴──────────────╯"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn table_expand_padding_not_default() {
|
||||
let actual = nu!("$env.config.table.padding = 5; [[a b, c]; [1 2 3] [4 5 [1 2 3]]] | table -e");
|
||||
assert_eq!(
|
||||
actual.out,
|
||||
"╭───────────┬───────────┬───────────┬───────────────────────────────────╮\
|
||||
│ # │ a │ b │ c │\
|
||||
├───────────┼───────────┼───────────┼───────────────────────────────────┤\
|
||||
│ 0 │ 1 │ 2 │ 3 │\
|
||||
│ 1 │ 4 │ 5 │ ╭───────────┬───────────╮ │\
|
||||
│ │ │ │ │ 0 │ 1 │ │\
|
||||
│ │ │ │ │ 1 │ 2 │ │\
|
||||
│ │ │ │ │ 2 │ 3 │ │\
|
||||
│ │ │ │ ╰───────────┴───────────╯ │\
|
||||
╰───────────┴───────────┴───────────┴───────────────────────────────────╯"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn table_expand_padding_zero() {
|
||||
let actual = nu!("$env.config.table.padding = {left: 0, right: 0}; [[a b, c]; [1 2 3] [4 5 [1 2 3]]] | table -e");
|
||||
assert_eq!(
|
||||
actual.out,
|
||||
"╭─┬─┬─┬─────╮\
|
||||
│#│a│b│ c │\
|
||||
├─┼─┼─┼─────┤\
|
||||
│0│1│2│ 3│\
|
||||
│1│4│5│╭─┬─╮│\
|
||||
│ │ │ ││0│1││\
|
||||
│ │ │ ││1│2││\
|
||||
│ │ │ ││2│3││\
|
||||
│ │ │ │╰─┴─╯│\
|
||||
╰─┴─┴─┴─────╯"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn table_collapse_padding_not_default() {
|
||||
let actual = nu!("$env.config.table.padding = 5; [[a b, c]; [1 2 3] [4 5 [1 2 3]]] | table -c");
|
||||
assert_eq!(
|
||||
actual.out,
|
||||
"╭───────────┬───────────┬───────────╮\
|
||||
│ a │ b │ c │\
|
||||
├───────────┼───────────┼───────────┤\
|
||||
│ 1 │ 2 │ 3 │\
|
||||
├───────────┼───────────┼───────────┤\
|
||||
│ 4 │ 5 │ 1 │\
|
||||
│ │ ├───────────┤\
|
||||
│ │ │ 2 │\
|
||||
│ │ ├───────────┤\
|
||||
│ │ │ 3 │\
|
||||
╰───────────┴───────────┴───────────╯"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn table_collapse_padding_zero() {
|
||||
let actual = nu!("$env.config.table.padding = {left: 0, right: 0}; [[a b, c]; [1 2 3] [4 5 [1 2 3]]] | table -c");
|
||||
assert_eq!(
|
||||
actual.out,
|
||||
"╭─┬─┬─╮\
|
||||
│a│b│c│\
|
||||
├─┼─┼─┤\
|
||||
│1│2│3│\
|
||||
├─┼─┼─┤\
|
||||
│4│5│1│\
|
||||
│ │ ├─┤\
|
||||
│ │ │2│\
|
||||
│ │ ├─┤\
|
||||
│ │ │3│\
|
||||
╰─┴─┴─╯"
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user