nushell/crates/nu-command/tests/commands/table.rs

1075 lines
121 KiB
Rust
Raw Normal View History

use nu_test_support::fs::Stub::FileWithContent;
use nu_test_support::playground::Playground;
use nu_test_support::{nu, pipeline};
WIP/ Checkout to new `tabled` (#6286) * nu-table/ Use latest tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table/ Fix first column alignment Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Fix cargo clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Fix color issue Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Fix footer row Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Update Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table/ Update * Use latest tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add optional -e, -c argument to `table` command for different view Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Update Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix cargo clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Add footer into -e/c mode Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Publish new expand mode Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add width ctrl for Expand mode Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Refactorings Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Refactorings Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Merge with main Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add record expand and fix empty list issue Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * refactoring Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2022-10-03 18:40:16 +02:00
#[test]
fn table_0() {
let actual = nu!(r#"[[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_collapse_0() {
let actual = nu!(r#"[[a b, c]; [1 2 3] [4 5 [1 2 3]]] | table --collapse"#);
assert_eq!(
actual.out,
"╭───┬───┬───╮│ a │ b │ c │ ─── ─── ─── │ 1 │ 2 │ 3 │ ─── ─── ─── │ 4 │ 5 │ 1 ││ │ ─── │ │ │ 2 ││ │ ─── │ │ │ 3 │╰───┴───┴───╯"
WIP/ Checkout to new `tabled` (#6286) * nu-table/ Use latest tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table/ Fix first column alignment Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Fix cargo clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Fix color issue Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Fix footer row Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Update Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table/ Update * Use latest tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add optional -e, -c argument to `table` command for different view Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Update Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix cargo clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Add footer into -e/c mode Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Publish new expand mode Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add width ctrl for Expand mode Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Refactorings Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Refactorings Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Merge with main Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add record expand and fix empty list issue Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * refactoring Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2022-10-03 18:40:16 +02:00
);
}
#[test]
fn table_expand_0() {
let actual = nu!(r#"[[a b, c]; [1 2 3] [4 5 [1 2 3]]] | table --expand"#);
assert_eq!(
actual.out,
"╭───┬───┬───┬───────────╮\
# a b c \
\
0 1 2 3 \
1 4 5 \
WIP/ Checkout to new `tabled` (#6286) * nu-table/ Use latest tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table/ Fix first column alignment Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Fix cargo clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Fix color issue Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Fix footer row Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Update Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table/ Update * Use latest tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add optional -e, -c argument to `table` command for different view Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Update Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix cargo clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Add footer into -e/c mode Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Publish new expand mode Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add width ctrl for Expand mode Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Refactorings Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Refactorings Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Merge with main Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add record expand and fix empty list issue Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * refactoring Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2022-10-03 18:40:16 +02:00
0 1 \
1 2 \
2 3 \
\
"
);
}
// I am not sure whether the test is platform dependent, cause we don't set a term_width on our own
#[test]
fn table_expand_exceed_overlap_0() {
// no expand
let actual = nu!(r#"[[a b, c]; [xxxxxxxxxxxxxxxxxxxxxx 2 3] [4 5 [1 2 3]]] | table --expand"#);
assert_eq!(
actual.out,
"╭───┬────────────────────────┬───┬───────────╮\
# a b c \
\
0 xxxxxxxxxxxxxxxxxxxxxx 2 3 \
1 4 5 \
0 1 \
1 2 \
2 3 \
\
",
);
// expand
let actual = nu!(
r#"[[a b, c]; [xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 2 3] [4 5 [1 2 3]]] | table --expand"#
);
assert_eq!(
actual.out,
"╭──────┬───────────────────────────────────────────────────┬─────┬─────────────╮\
# a b c \
\
0 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 2 3 \
1 4 5 \
0 1 \
1 2 \
2 3 \
\
"
);
}
WIP/ Checkout to new `tabled` (#6286) * nu-table/ Use latest tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table/ Fix first column alignment Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Fix cargo clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Fix color issue Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Fix footer row Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Update Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table/ Update * Use latest tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add optional -e, -c argument to `table` command for different view Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Update Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix cargo clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Add footer into -e/c mode Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Publish new expand mode Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add width ctrl for Expand mode Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Refactorings Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Refactorings Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Merge with main Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add record expand and fix empty list issue Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * refactoring Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2022-10-03 18:40:16 +02:00
#[test]
fn table_expand_deep_0() {
let actual = nu!(r#"[[a b, c]; [1 2 3] [4 5 [1 2 [1 2 3]]]] | table --expand --expand-deep=1"#);
assert_eq!(
actual.out,
"╭───┬───┬───┬────────────────────────╮\
# a b c \
\
0 1 2 3 \
1 4 5 \
WIP/ Checkout to new `tabled` (#6286) * nu-table/ Use latest tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table/ Fix first column alignment Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Fix cargo clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Fix color issue Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Fix footer row Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Update Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table/ Update * Use latest tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add optional -e, -c argument to `table` command for different view Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Update Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix cargo clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Add footer into -e/c mode Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Publish new expand mode Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add width ctrl for Expand mode Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Refactorings Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Refactorings Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Merge with main Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add record expand and fix empty list issue Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * refactoring Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2022-10-03 18:40:16 +02:00
0 1 \
1 2 \
2 [list 3 items] \
\
"
);
}
#[test]
fn table_expand_deep_1() {
let actual = nu!(r#"[[a b, c]; [1 2 3] [4 5 [1 2 [1 2 3]]]] | table --expand --expand-deep=0"#);
assert_eq!(
actual.out,
"╭───┬───┬───┬────────────────╮\
# a b c \
\
0 1 2 3 \
1 4 5 [list 3 items] \
WIP/ Checkout to new `tabled` (#6286) * nu-table/ Use latest tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table/ Fix first column alignment Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Fix cargo clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Fix color issue Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Fix footer row Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Update Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table/ Update * Use latest tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add optional -e, -c argument to `table` command for different view Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Update Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix cargo clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Add footer into -e/c mode Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Publish new expand mode Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add width ctrl for Expand mode Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Refactorings Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Refactorings Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Merge with main Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add record expand and fix empty list issue Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * refactoring Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2022-10-03 18:40:16 +02:00
"
);
}
#[test]
fn table_expand_flatten_0() {
let actual = nu!(r#"[[a b, c]; [1 2 3] [4 5 [1 2 [1 1 1]]]] | table --expand --flatten "#);
assert_eq!(
actual.out,
"╭───┬───┬───┬───────────────╮\
# a b c \
\
0 1 2 3 \
1 4 5 \
WIP/ Checkout to new `tabled` (#6286) * nu-table/ Use latest tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table/ Fix first column alignment Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Fix cargo clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Fix color issue Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Fix footer row Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Update Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table/ Update * Use latest tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add optional -e, -c argument to `table` command for different view Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Update Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix cargo clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Add footer into -e/c mode Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Publish new expand mode Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add width ctrl for Expand mode Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Refactorings Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Refactorings Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Merge with main Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add record expand and fix empty list issue Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * refactoring Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2022-10-03 18:40:16 +02:00
0 1 \
1 2 \
2 1 1 1 \
\
"
);
}
#[test]
fn table_expand_flatten_1() {
let actual = nu!(
r#"[[a b, c]; [1 2 3] [4 5 [1 2 [1 1 1]]]] | table --expand --flatten --flatten-separator=,"#
);
assert_eq!(
actual.out,
"╭───┬───┬───┬───────────────╮\
# a b c \
\
0 1 2 3 \
1 4 5 \
WIP/ Checkout to new `tabled` (#6286) * nu-table/ Use latest tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table/ Fix first column alignment Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Fix cargo clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Fix color issue Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Fix footer row Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Update Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table/ Update * Use latest tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add optional -e, -c argument to `table` command for different view Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Update Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix cargo clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Add footer into -e/c mode Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Publish new expand mode Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add width ctrl for Expand mode Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Refactorings Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Refactorings Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Merge with main Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add record expand and fix empty list issue Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * refactoring Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2022-10-03 18:40:16 +02:00
0 1 \
1 2 \
2 1,1,1 \
\
"
);
}
#[test]
fn table_expand_flatten_and_deep_1() {
let actual = nu!(
r#"[[a b, c]; [1 2 3] [4 5 [1 2 [1 [1 1 1] 1]]]] | table --expand --expand-deep=2 --flatten --flatten-separator=,"#
);
assert_eq!(
actual.out,
"╭───┬───┬───┬────────────────────────────────╮\
# a b c \
\
0 1 2 3 \
1 4 5 \
WIP/ Checkout to new `tabled` (#6286) * nu-table/ Use latest tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table/ Fix first column alignment Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Fix cargo clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Fix color issue Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Fix footer row Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Update Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table/ Update * Use latest tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add optional -e, -c argument to `table` command for different view Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Update Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix cargo clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Add footer into -e/c mode Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Publish new expand mode Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add width ctrl for Expand mode Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Refactorings Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Refactorings Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Merge with main Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix clippy Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix tests Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Bump tabled Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add record expand and fix empty list issue Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * refactoring Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2022-10-03 18:40:16 +02:00
0 1 \
1 2 \
2 \
0 1 \
1 [list 3 items] \
2 1 \
\
\
"
);
}
#[test]
#[cfg(not(windows))]
fn external_with_too_much_stdout_should_not_hang_nu() {
use nu_test_support::fs::Stub::FileWithContent;
use nu_test_support::pipeline;
use nu_test_support::playground::Playground;
Playground::setup("external with too much stdout", |dirs, sandbox| {
let bytes: usize = 81920;
let mut large_file_body = String::with_capacity(bytes);
for _ in 0..bytes {
2022-10-18 20:13:36 +02:00
large_file_body.push('a');
}
sandbox.with_files(vec![FileWithContent("a_large_file.txt", &large_file_body)]);
let actual = nu!(
cwd: dirs.test(), pipeline(
r#"
cat a_large_file.txt | table
"#
));
assert_eq!(actual.out, large_file_body);
})
}
#[test]
fn table_pagging_row_offset_overlap() {
let actual = nu!(r#"0..1000"#);
assert_eq!(actual.out, "╭─────┬─────╮│ 0 │ 0 ││ 1 │ 1 ││ 2 │ 2 ││ 3 │ 3 ││ 4 │ 4 ││ 5 │ 5 ││ 6 │ 6 ││ 7 │ 7 ││ 8 │ 8 ││ 9 │ 9 ││ 10 │ 10 ││ 11 │ 11 ││ 12 │ 12 ││ 13 │ 13 ││ 14 │ 14 ││ 15 │ 15 ││ 16 │ 16 ││ 17 │ 17 ││ 18 │ 18 ││ 19 │ 19 ││ 20 │ 20 ││ 21 │ 21 ││ 22 │ 22 ││ 23 │ 23 ││ 24 │ 24 ││ 25 │ 25 ││ 26 │ 26 ││ 27 │ 27 ││ 28 │ 28 ││ 29 │ 29 ││ 30 │ 30 ││ 31 │ 31 ││ 32 │ 32 ││ 33 │ 33 ││ 34 │ 34 ││ 35 │ 35 ││ 36 │ 36 ││ 37 │ 37 ││ 38 │ 38 ││ 39 │ 39 ││ 40 │ 40 ││ 41 │ 41 ││ 42 │ 42 ││ 43 │ 43 ││ 44 │ 44 ││ 45 │ 45 ││ 46 │ 46 ││ 47 │ 47 ││ 48 │ 48 ││ 49 │ 49 ││ 50 │ 50 ││ 51 │ 51 ││ 52 │ 52 ││ 53 │ 53 ││ 54 │ 54 ││ 55 │ 55 ││ 56 │ 56 ││ 57 │ 57 ││ 58 │ 58 ││ 59 │ 59 ││ 60 │ 60 ││ 61 │ 61 ││ 62 │ 62 ││ 63 │ 63 ││ 64 │ 64 ││ 65 │ 65 ││ 66 │ 66 ││ 67 │ 67 ││ 68 │ 68 ││ 69 │ 69 ││ 70 │ 70 ││ 71 │ 71 ││ 72 │ 72 ││ 73 │ 73 ││ 74 │ 74 ││ 75 │ 75 ││ 76 │ 76 ││ 77 │ 77 ││ 78 │ 78 ││ 79 │ 79 ││ 80 │ 80 ││ 81 │ 81 ││ 82 │ 82 ││ 83 │ 83 ││ 84 │ 84 ││ 85 │ 85 ││ 86 │ 86 ││ 87 │ 87 ││ 88 │ 88 ││ 89 │ 89 ││ 90 │ 90 ││ 91 │ 91 ││ 92 │ 92 ││ 93 │ 93 ││ 94 │ 94 ││ 95 │ 95 ││ 96 │ 96 ││ 97 │ 97 ││ 98 │ 98 ││ 99 │ 99 ││ 100 │ 100 ││ 101 │ 101 ││ 102 │ 102 ││ 103 │ 103 ││ 104 │ 104 ││ 105 │ 105 ││ 106 │ 106 ││ 107 │ 107 ││ 108 │ 108 ││ 109 │ 109 ││ 110 │ 110 ││ 111 │ 111 ││ 112 │ 112 ││ 113 │ 113 ││ 114 │ 114 ││ 115 │ 115 ││ 116 │ 116 ││ 117 │ 117 ││ 118 │ 118 ││ 119 │ 119 ││ 120 │ 120 ││ 121 │ 121 ││ 122 │ 122 ││ 123 │ 123 ││ 124 │ 124 ││ 125 │ 125 ││ 126 │ 126 ││ 127 │ 127 ││ 128 │ 128 ││ 129 │ 129 ││ 130 │ 130 ││ 131 │ 131 ││ 132 │ 132 ││ 133 │ 133 ││ 134 │ 134 ││ 135 │ 135 ││ 136 │ 136 ││ 137 │ 137 ││ 138 │ 138 ││ 139 │ 139 ││ 140 │ 140 ││ 141 │ 141 ││ 142 │ 142 ││ 143 │ 143 ││ 144 │ 144 ││ 145 │ 145 ││ 146 │ 146 ││ 147 │ 147 ││ 148 │ 148 ││ 149 │ 149 ││ 150 │ 150 ││ 151 │ 151 ││ 152 │ 152 ││ 153 │ 153 ││ 154 │ 154 ││ 155 │ 155 ││ 156 │ 156 ││ 157 │ 157 ││ 158 │ 158 ││ 159 │ 159 ││ 160 │ 160 ││ 161 │ 161 ││ 162 │ 162 ││ 163 │ 163 ││ 164 │ 164 ││ 165 │ 165 ││ 166 │ 166 ││ 167 │ 167 ││ 168 │ 168 ││ 169 │ 169 ││ 170 │ 170 ││ 171 │ 171 ││ 172 │ 172 ││ 173 │ 173 ││ 174 │ 174 ││ 175 │ 175 ││ 176 │ 176 ││ 177 │ 177 ││ 178 │ 178 ││ 179 │ 179 ││ 180 │ 180 ││ 181 │ 181 ││ 182 │ 182 ││ 183 │ 183 ││ 184 │ 184 ││ 185 │ 185 ││ 186 │ 186 ││ 187 │ 187 ││ 188 │ 188 ││ 189 │ 189 ││ 190 │ 190 ││ 191 │ 191 ││ 192 │ 192 ││ 193 │ 193 ││ 194 │ 194 ││ 195 │ 195 ││ 196 │ 196 ││ 197 │ 197 ││ 198 │ 198 ││ 199 │ 199 ││ 200 │ 200 ││ 201 │ 201 ││ 202 │ 202 ││ 203 │ 203 ││ 204 │ 204 ││ 205 │ 205 ││ 206 │ 206 ││ 207 │ 207 ││ 208 │ 208 ││ 209 │ 209 ││ 210 │ 210 ││ 211 │ 211 │
}
#[test]
fn table_index_0() {
let actual = nu!(r#"[1 3 1 3 2 1 1]"#);
assert_eq!(
actual.out,
"╭───┬───╮│ 0 │ 1 ││ 1 │ 3 ││ 2 │ 1 ││ 3 │ 3 ││ 4 │ 2 ││ 5 │ 1 ││ 6 │ 1 │╰───┴───╯"
);
}
#[test]
fn test_expand_big_0() {
Playground::setup("test_expand_big_0", |dirs, sandbox| {
sandbox.with_files(vec![FileWithContent(
"sample.toml",
r#"
[package]
authors = ["The Nushell Project Developers"]
default-run = "nu"
description = "A new type of shell"
documentation = "https://www.nushell.sh/book/"
edition = "2021"
exclude = ["images"]
homepage = "https://www.nushell.sh"
license = "MIT"
name = "nu"
repository = "https://github.com/nushell/nushell"
rust-version = "1.60"
version = "0.74.1"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[package.metadata.binstall]
pkg-url = "{ repo }/releases/download/{ version }/{ name }-{ version }-{ target }.{ archive-format }"
pkg-fmt = "tgz"
[package.metadata.binstall.overrides.x86_64-pc-windows-msvc]
pkg-fmt = "zip"
[workspace]
members = [
"crates/nu-cli",
"crates/nu-engine",
"crates/nu-parser",
"crates/nu-system",
"crates/nu-command",
"crates/nu-protocol",
"crates/nu-plugin",
"crates/nu_plugin_inc",
"crates/nu_plugin_gstat",
"crates/nu_plugin_example",
"crates/nu_plugin_query",
"crates/nu_plugin_custom_values",
"crates/nu-utils",
]
[dependencies]
chrono = { version = "0.4.23", features = ["serde"] }
crossterm = "0.24.0"
ctrlc = "3.2.1"
log = "0.4"
miette = { version = "5.5.0", features = ["fancy-no-backtrace"] }
nu-ansi-term = "0.46.0"
nu-cli = { path = "./crates/nu-cli", version = "0.74.1" }
nu-engine = { path = "./crates/nu-engine", version = "0.74.1" }
reedline = { version = "0.14.0", features = ["bashisms", "sqlite"] }
rayon = "1.6.1"
is_executable = "1.0.1"
simplelog = "0.12.0"
time = "0.3.12"
[target.'cfg(not(target_os = "windows"))'.dependencies]
# Our dependencies don't use OpenSSL on Windows
openssl = { version = "0.10.38", features = ["vendored"], optional = true }
signal-hook = { version = "0.3.14", default-features = false }
[target.'cfg(windows)'.build-dependencies]
winres = "0.1"
[target.'cfg(target_family = "unix")'.dependencies]
nix = { version = "0.25", default-features = false, features = ["signal", "process", "fs", "term"] }
atty = "0.2"
[dev-dependencies]
nu-test-support = { path = "./crates/nu-test-support", version = "0.74.1" }
tempfile = "3.2.0"
assert_cmd = "2.0.2"
criterion = "0.4"
pretty_assertions = "1.0.0"
serial_test = "0.10.0"
hamcrest2 = "0.3.0"
rstest = { version = "0.15.0", default-features = false }
itertools = "0.10.3"
[features]
plugin = [
"nu-plugin",
"nu-cli/plugin",
"nu-parser/plugin",
"nu-command/plugin",
"nu-protocol/plugin",
"nu-engine/plugin",
]
# extra used to be more useful but now it's the same as default. Leaving it in for backcompat with existing build scripts
extra = ["default"]
default = ["plugin", "which-support", "trash-support", "sqlite"]
stable = ["default"]
wasi = []
# Enable to statically link OpenSSL; otherwise the system version will be used. Not enabled by default because it takes a while to build
static-link-openssl = ["dep:openssl"]
# Stable (Default)
which-support = ["nu-command/which-support"]
trash-support = ["nu-command/trash-support"]
# Main nu binary
[[bin]]
name = "nu"
path = "src/main.rs"
# To use a development version of a dependency please use a global override here
# changing versions in each sub-crate of the workspace is tedious
[patch.crates-io]
reedline = { git = "https://github.com/nushell/reedline.git", branch = "main" }
# Criterion benchmarking setup
# Run all benchmarks with `cargo bench`
# Run individual benchmarks like `cargo bench -- <regex>` e.g. `cargo bench -- parse`
[[bench]]
name = "benchmarks"
harness = false
"#,
)]);
let actual = nu!(
cwd: dirs.test(), pipeline(
"open sample.toml | table --expand"
));
_print_lines(&actual.out, 80);
let expected = join_lines([
"╭──────────────────┬───────────────────────────────────────────────────────────╮",
"│ │ ╭───┬─────────┬────────────╮ │",
"│ bench │ │ # │ harness │ name │ │",
"│ │ ├───┼─────────┼────────────┤ │",
"│ │ │ 0 │ false │ benchmarks │ │",
"│ │ ╰───┴─────────┴────────────╯ │",
"│ │ ╭───┬──────┬─────────────╮ │",
"│ bin │ │ # │ name │ path │ │",
"│ │ ├───┼──────┼─────────────┤ │",
"│ │ │ 0 │ nu │ src/main.rs │ │",
"│ │ ╰───┴──────┴─────────────╯ │",
"│ │ ╭───────────────┬───────────────────────────────────────╮ │",
"│ dependencies │ │ │ ╭──────────┬───────────────╮ │ │",
"│ │ │ chrono │ │ │ ╭───┬───────╮ │ │ │",
"│ │ │ │ │ features │ │ 0 │ serde │ │ │ │",
"│ │ │ │ │ │ ╰───┴───────╯ │ │ │",
"│ │ │ │ │ version │ 0.4.23 │ │ │",
"│ │ │ │ ╰──────────┴───────────────╯ │ │",
"│ │ │ crossterm │ 0.24.0 │ │",
"│ │ │ ctrlc │ 3.2.1 │ │",
"│ │ │ is_executable │ 1.0.1 │ │",
"│ │ │ log │ 0.4 │ │",
"│ │ │ │ ╭──────────┬────────────────────────╮ │ │",
"│ │ │ miette │ │ │ ╭───┬────────────────╮ │ │ │",
"│ │ │ │ │ features │ │ 0 │ fancy-no-backt │ │ │ │",
"│ │ │ │ │ │ │ │ race │ │ │ │",
"│ │ │ │ │ │ ╰───┴────────────────╯ │ │ │",
"│ │ │ │ │ version │ 5.5.0 │ │ │",
"│ │ │ │ ╰──────────┴────────────────────────╯ │ │",
"│ │ │ nu-ansi-term │ 0.46.0 │ │",
"│ │ │ │ ╭─────────┬─────────────────╮ │ │",
"│ │ │ nu-cli │ │ path │ ./crates/nu-cli │ │ │",
"│ │ │ │ │ version │ 0.74.1 │ │ │",
"│ │ │ │ ╰─────────┴─────────────────╯ │ │",
"│ │ │ │ ╭────────────┬──────────────────────╮ │ │",
"│ │ │ nu-engine │ │ path │ ./crates/nu-engine │ │ │",
"│ │ │ │ │ version │ 0.74.1 │ │ │",
"│ │ │ │ ╰────────────┴──────────────────────╯ │ │",
"│ │ │ rayon │ 1.6.1 │ │",
"│ │ │ │ ╭─────────────┬─────────────────────╮ │ │",
"│ │ │ reedline │ │ │ ╭───┬──────────╮ │ │ │",
"│ │ │ │ │ features │ │ 0 │ bashisms │ │ │ │",
"│ │ │ │ │ │ │ 1 │ sqlite │ │ │ │",
"│ │ │ │ │ │ ╰───┴──────────╯ │ │ │",
"│ │ │ │ │ version │ 0.14.0 │ │ │",
"│ │ │ │ ╰─────────────┴─────────────────────╯ │ │",
"│ │ │ simplelog │ 0.12.0 │ │",
"│ │ │ time │ 0.3.12 │ │",
"│ │ ╰───────────────┴───────────────────────────────────────╯ │",
"│ │ ╭───────────────────┬───────────────────────────────────╮ │",
"│ dev-dependencies │ │ assert_cmd │ 2.0.2 │ │",
"│ │ │ criterion │ 0.4 │ │",
"│ │ │ hamcrest2 │ 0.3.0 │ │",
"│ │ │ itertools │ 0.10.3 │ │",
"│ │ │ │ ╭─────────┬─────────────────────╮ │ │",
"│ │ │ nu-test-support │ │ path │ ./crates/nu-test-su │ │ │",
"│ │ │ │ │ │ pport │ │ │",
"│ │ │ │ │ version │ 0.74.1 │ │ │",
"│ │ │ │ ╰─────────┴─────────────────────╯ │ │",
"│ │ │ pretty_assertions │ 1.0.0 │ │",
"│ │ │ │ ╭────────────────────┬──────────╮ │ │",
"│ │ │ rstest │ │ default-features │ false │ │ │",
"│ │ │ │ │ version │ 0.15.0 │ │ │",
"│ │ │ │ ╰────────────────────┴──────────╯ │ │",
"│ │ │ serial_test │ 0.10.0 │ │",
"│ │ │ tempfile │ 3.2.0 │ │",
"│ │ ╰───────────────────┴───────────────────────────────────╯ │",
"│ │ ╭─────────────────────┬─────────────────────────────────╮ │",
"│ features │ │ │ ╭───┬───────────────╮ │ │",
"│ │ │ default │ │ 0 │ plugin │ │ │",
"│ │ │ │ │ 1 │ which-support │ │ │",
"│ │ │ │ │ 2 │ trash-support │ │ │",
"│ │ │ │ │ 3 │ sqlite │ │ │",
"│ │ │ │ ╰───┴───────────────╯ │ │",
"│ │ │ │ ╭───┬─────────╮ │ │",
"│ │ │ extra │ │ 0 │ default │ │ │",
"│ │ │ │ ╰───┴─────────╯ │ │",
"│ │ │ │ ╭───┬────────────────────╮ │ │",
"│ │ │ plugin │ │ 0 │ nu-plugin │ │ │",
"│ │ │ │ │ 1 │ nu-cli/plugin │ │ │",
"│ │ │ │ │ 2 │ nu-parser/plugin │ │ │",
"│ │ │ │ │ 3 │ nu-command/plugin │ │ │",
"│ │ │ │ │ 4 │ nu-protocol/plugin │ │ │",
"│ │ │ │ │ 5 │ nu-engine/plugin │ │ │",
"│ │ │ │ ╰───┴────────────────────╯ │ │",
"│ │ │ │ ╭───┬─────────╮ │ │",
"│ │ │ stable │ │ 0 │ default │ │ │",
"│ │ │ │ ╰───┴─────────╯ │ │",
"│ │ │ │ ╭───┬─────────────╮ │ │",
"│ │ │ static-link-openssl │ │ 0 │ dep:openssl │ │ │",
"│ │ │ │ ╰───┴─────────────╯ │ │",
"│ │ │ │ ╭───┬─────────────────────────╮ │ │",
"│ │ │ trash-support │ │ 0 │ nu-command/trash-suppor │ │ │",
"│ │ │ │ │ │ t │ │ │",
"│ │ │ │ ╰───┴─────────────────────────╯ │ │",
"│ │ │ wasi │ [list 0 items] │ │",
"│ │ │ │ ╭───┬─────────────────────────╮ │ │",
"│ │ │ which-support │ │ 0 │ nu-command/which-suppor │ │ │",
"│ │ │ │ │ │ t │ │ │",
"│ │ │ │ ╰───┴─────────────────────────╯ │ │",
"│ │ ╰─────────────────────┴─────────────────────────────────╯ │",
"│ │ ╭───────────────┬───────────────────────────────────────╮ │",
"│ package │ │ │ ╭───┬───────────────────────────────╮ │ │",
"│ │ │ authors │ │ 0 │ The Nushell Project │ │ │",
"│ │ │ │ │ │ Developers │ │ │",
"│ │ │ │ ╰───┴───────────────────────────────╯ │ │",
"│ │ │ default-run │ nu │ │",
"│ │ │ description │ A new type of shell │ │",
"│ │ │ documentation │ https://www.nushell.sh/book/ │ │",
"│ │ │ edition │ 2021 │ │",
"│ │ │ │ ╭───┬────────╮ │ │",
"│ │ │ exclude │ │ 0 │ images │ │ │",
"│ │ │ │ ╰───┴────────╯ │ │",
"│ │ │ homepage │ https://www.nushell.sh │ │",
"│ │ │ license │ MIT │ │",
"│ │ │ │ ╭──────────┬────────────────────────╮ │ │",
"│ │ │ metadata │ │ │ ╭───────────┬────────╮ │ │ │",
"│ │ │ │ │ binstall │ │ overrides │ {recor │ │ │ │",
"│ │ │ │ │ │ │ │ d 1 │ │ │ │",
"│ │ │ │ │ │ │ │ field} │ │ │ │",
"│ │ │ │ │ │ │ pkg-fmt │ tgz │ │ │ │",
"│ │ │ │ │ │ │ pkg-url │ { repo │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ │ │",
"│ │ │ │ │ │ │ │ }/rele │ │ │ │",
"│ │ │ │ │ │ │ │ ases/d │ │ │ │",
"│ │ │ │ │ │ │ │ ownloa │ │ │ │",
"│ │ │ │ │ │ │ │ d/{ │ │ │ │",
"│ │ │ │ │ │ │ │ versio │ │ │ │",
"│ │ │ │ │ │ │ │ n }/{ │ │ │ │",
"│ │ │ │ │ │ │ │ name │ │ │ │",
"│ │ │ │ │ │ │ │ }-{ │ │ │ │",
"│ │ │ │ │ │ │ │ versio │ │ │ │",
"│ │ │ │ │ │ │ │ n }-{ │ │ │ │",
"│ │ │ │ │ │ │ │ target │ │ │ │",
"│ │ │ │ │ │ │ │ }.{ │ │ │ │",
"│ │ │ │ │ │ │ │ archiv │ │ │ │",
"│ │ │ │ │ │ │ │ e-form │ │ │ │",
"│ │ │ │ │ │ │ │ at } │ │ │ │",
"│ │ │ │ │ │ ╰───────────┴────────╯ │ │ │",
"│ │ │ │ ╰──────────┴────────────────────────╯ │ │",
"│ │ │ name │ nu │ │",
"│ │ │ repository │ https://github.com/nushell/nushell │ │",
"│ │ │ rust-version │ 1.60 │ │",
"│ │ │ version │ 0.74.1 │ │",
"│ │ ╰───────────────┴───────────────────────────────────────╯ │",
"│ │ ╭───────────┬───────────────────────────────────────────╮ │",
"│ patch │ │ │ ╭──────────┬────────────────────────────╮ │ │",
"│ │ │ crates-io │ │ │ ╭────────┬───────────────╮ │ │ │",
"│ │ │ │ │ reedline │ │ branch │ main │ │ │ │",
"│ │ │ │ │ │ │ git │ https://githu │ │ │ │",
"│ │ │ │ │ │ │ │ b.com/nushell │ │ │ │",
"│ │ │ │ │ │ │ │ /reedline.git │ │ │ │",
"│ │ │ │ │ │ ╰────────┴───────────────╯ │ │ │",
"│ │ │ │ ╰──────────┴────────────────────────────╯ │ │",
"│ │ ╰───────────┴───────────────────────────────────────────╯ │",
"│ │ ╭─────────────────────────────────┬─────────────────────╮ │",
"│ target │ │ │ ╭──────────────┬──╮ │ │",
"│ │ │ cfg(not(target_os = \"windows\")) │ │ dependencies │ │ │ │",
"│ │ │ │ ╰──────────────┴──╯ │ │",
"│ │ │ │ ╭──────────────┬──╮ │ │",
"│ │ │ cfg(target_family = \"unix\") │ │ dependencies │ │ │ │",
"│ │ │ │ ╰──────────────┴──╯ │ │",
"│ │ │ cfg(windows) │ {record 1 field} │ │",
"│ │ ╰─────────────────────────────────┴─────────────────────╯ │",
"│ │ ╭───────────┬───────────────────────────────────────────╮ │",
"│ workspace │ │ │ ╭────┬────────────────────────────────╮ │ │",
"│ │ │ members │ │ 0 │ crates/nu-cli │ │ │",
"│ │ │ │ │ 1 │ crates/nu-engine │ │ │",
"│ │ │ │ │ 2 │ crates/nu-parser │ │ │",
"│ │ │ │ │ 3 │ crates/nu-system │ │ │",
"│ │ │ │ │ 4 │ crates/nu-command │ │ │",
"│ │ │ │ │ 5 │ crates/nu-protocol │ │ │",
"│ │ │ │ │ 6 │ crates/nu-plugin │ │ │",
"│ │ │ │ │ 7 │ crates/nu_plugin_inc │ │ │",
"│ │ │ │ │ 8 │ crates/nu_plugin_gstat │ │ │",
"│ │ │ │ │ 9 │ crates/nu_plugin_example │ │ │",
"│ │ │ │ │ 10 │ crates/nu_plugin_query │ │ │",
"│ │ │ │ │ 11 │ crates/nu_plugin_custom_values │ │ │",
"│ │ │ │ │ 12 │ crates/nu-utils │ │ │",
"│ │ │ │ ╰────┴────────────────────────────────╯ │ │",
"│ │ ╰───────────┴───────────────────────────────────────────╯ │",
"╰──────────────────┴───────────────────────────────────────────────────────────╯",
]);
assert_eq!(actual.out, expected);
let actual = nu!(
cwd: dirs.test(), pipeline(
"open sample.toml | table --expand --width=120"
));
_print_lines(&actual.out, 120);
let expected = join_lines([
"╭──────────────────┬───────────────────────────────────────────────────────────────────────────────────────────────────╮",
"│ │ ╭───┬─────────┬────────────╮ │",
"│ bench │ │ # │ harness │ name │ │",
"│ │ ├───┼─────────┼────────────┤ │",
"│ │ │ 0 │ false │ benchmarks │ │",
"│ │ ╰───┴─────────┴────────────╯ │",
"│ │ ╭───┬──────┬─────────────╮ │",
"│ bin │ │ # │ name │ path │ │",
"│ │ ├───┼──────┼─────────────┤ │",
"│ │ │ 0 │ nu │ src/main.rs │ │",
"│ │ ╰───┴──────┴─────────────╯ │",
"│ │ ╭───────────────┬───────────────────────────────────────────╮ │",
"│ dependencies │ │ │ ╭──────────┬───────────────╮ │ │",
"│ │ │ chrono │ │ │ ╭───┬───────╮ │ │ │",
"│ │ │ │ │ features │ │ 0 │ serde │ │ │ │",
"│ │ │ │ │ │ ╰───┴───────╯ │ │ │",
"│ │ │ │ │ version │ 0.4.23 │ │ │",
"│ │ │ │ ╰──────────┴───────────────╯ │ │",
"│ │ │ crossterm │ 0.24.0 │ │",
"│ │ │ ctrlc │ 3.2.1 │ │",
"│ │ │ is_executable │ 1.0.1 │ │",
"│ │ │ log │ 0.4 │ │",
"│ │ │ │ ╭──────────┬────────────────────────────╮ │ │",
"│ │ │ miette │ │ │ ╭───┬────────────────────╮ │ │ │",
"│ │ │ │ │ features │ │ 0 │ fancy-no-backtrace │ │ │ │",
"│ │ │ │ │ │ ╰───┴────────────────────╯ │ │ │",
"│ │ │ │ │ version │ 5.5.0 │ │ │",
"│ │ │ │ ╰──────────┴────────────────────────────╯ │ │",
"│ │ │ nu-ansi-term │ 0.46.0 │ │",
"│ │ │ │ ╭─────────┬─────────────────╮ │ │",
"│ │ │ nu-cli │ │ path │ ./crates/nu-cli │ │ │",
"│ │ │ │ │ version │ 0.74.1 │ │ │",
"│ │ │ │ ╰─────────┴─────────────────╯ │ │",
"│ │ │ │ ╭─────────┬────────────────────╮ │ │",
"│ │ │ nu-engine │ │ path │ ./crates/nu-engine │ │ │",
"│ │ │ │ │ version │ 0.74.1 │ │ │",
"│ │ │ │ ╰─────────┴────────────────────╯ │ │",
"│ │ │ rayon │ 1.6.1 │ │",
"│ │ │ │ ╭──────────┬──────────────────╮ │ │",
"│ │ │ reedline │ │ │ ╭───┬──────────╮ │ │ │",
"│ │ │ │ │ features │ │ 0 │ bashisms │ │ │ │",
"│ │ │ │ │ │ │ 1 │ sqlite │ │ │ │",
"│ │ │ │ │ │ ╰───┴──────────╯ │ │ │",
"│ │ │ │ │ version │ 0.14.0 │ │ │",
"│ │ │ │ ╰──────────┴──────────────────╯ │ │",
"│ │ │ simplelog │ 0.12.0 │ │",
"│ │ │ time │ 0.3.12 │ │",
"│ │ ╰───────────────┴───────────────────────────────────────────╯ │",
"│ │ ╭───────────────────┬────────────────────────────────────────╮ │",
"│ dev-dependencies │ │ assert_cmd │ 2.0.2 │ │",
"│ │ │ criterion │ 0.4 │ │",
"│ │ │ hamcrest2 │ 0.3.0 │ │",
"│ │ │ itertools │ 0.10.3 │ │",
"│ │ │ │ ╭─────────┬──────────────────────────╮ │ │",
"│ │ │ nu-test-support │ │ path │ ./crates/nu-test-support │ │ │",
"│ │ │ │ │ version │ 0.74.1 │ │ │",
"│ │ │ │ ╰─────────┴──────────────────────────╯ │ │",
"│ │ │ pretty_assertions │ 1.0.0 │ │",
"│ │ │ │ ╭──────────────────┬────────╮ │ │",
"│ │ │ rstest │ │ default-features │ false │ │ │",
"│ │ │ │ │ version │ 0.15.0 │ │ │",
"│ │ │ │ ╰──────────────────┴────────╯ │ │",
"│ │ │ serial_test │ 0.10.0 │ │",
"│ │ │ tempfile │ 3.2.0 │ │",
"│ │ ╰───────────────────┴────────────────────────────────────────╯ │",
"│ │ ╭─────────────────────┬──────────────────────────────────╮ │",
"│ features │ │ │ ╭───┬───────────────╮ │ │",
"│ │ │ default │ │ 0 │ plugin │ │ │",
"│ │ │ │ │ 1 │ which-support │ │ │",
"│ │ │ │ │ 2 │ trash-support │ │ │",
"│ │ │ │ │ 3 │ sqlite │ │ │",
"│ │ │ │ ╰───┴───────────────╯ │ │",
"│ │ │ │ ╭───┬─────────╮ │ │",
"│ │ │ extra │ │ 0 │ default │ │ │",
"│ │ │ │ ╰───┴─────────╯ │ │",
"│ │ │ │ ╭───┬────────────────────╮ │ │",
"│ │ │ plugin │ │ 0 │ nu-plugin │ │ │",
"│ │ │ │ │ 1 │ nu-cli/plugin │ │ │",
"│ │ │ │ │ 2 │ nu-parser/plugin │ │ │",
"│ │ │ │ │ 3 │ nu-command/plugin │ │ │",
"│ │ │ │ │ 4 │ nu-protocol/plugin │ │ │",
"│ │ │ │ │ 5 │ nu-engine/plugin │ │ │",
"│ │ │ │ ╰───┴────────────────────╯ │ │",
"│ │ │ │ ╭───┬─────────╮ │ │",
"│ │ │ stable │ │ 0 │ default │ │ │",
"│ │ │ │ ╰───┴─────────╯ │ │",
"│ │ │ │ ╭───┬─────────────╮ │ │",
"│ │ │ static-link-openssl │ │ 0 │ dep:openssl │ │ │",
"│ │ │ │ ╰───┴─────────────╯ │ │",
"│ │ │ │ ╭───┬──────────────────────────╮ │ │",
"│ │ │ trash-support │ │ 0 │ nu-command/trash-support │ │ │",
"│ │ │ │ ╰───┴──────────────────────────╯ │ │",
"│ │ │ wasi │ [list 0 items] │ │",
"│ │ │ │ ╭───┬──────────────────────────╮ │ │",
"│ │ │ which-support │ │ 0 │ nu-command/which-support │ │ │",
"│ │ │ │ ╰───┴──────────────────────────╯ │ │",
"│ │ ╰─────────────────────┴──────────────────────────────────╯ │",
"│ │ ╭───────────────┬───────────────────────────────────────────────────────────────────────────────╮ │",
"│ package │ │ │ ╭───┬────────────────────────────────╮ │ │",
"│ │ │ authors │ │ 0 │ The Nushell Project Developers │ │ │",
"│ │ │ │ ╰───┴────────────────────────────────╯ │ │",
"│ │ │ default-run │ nu │ │",
"│ │ │ description │ A new type of shell │ │",
"│ │ │ documentation │ https://www.nushell.sh/book/ │ │",
"│ │ │ edition │ 2021 │ │",
"│ │ │ │ ╭───┬────────╮ │ │",
"│ │ │ exclude │ │ 0 │ images │ │ │",
"│ │ │ │ ╰───┴────────╯ │ │",
"│ │ │ homepage │ https://www.nushell.sh │ │",
"│ │ │ license │ MIT │ │",
"│ │ │ │ ╭──────────┬────────────────────────────────────────────────────────────────╮ │ │",
"│ │ │ metadata │ │ │ ╭───────────┬────────────────────────────────────────────────╮ │ │ │",
"│ │ │ │ │ binstall │ │ │ ╭────────────────────────┬───────────────────╮ │ │ │ │",
"│ │ │ │ │ │ │ overrides │ │ │ ╭─────────┬─────╮ │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ x86_64-pc-windows-msvc │ │ pkg-fmt │ zip │ │ │ │ │ │",
"│ │ │ │ │ │ │ │ │ │ ╰─────────┴─────╯ │ │ │ │ │",
"│ │ │ │ │ │ │ │ ╰────────────────────────┴───────────────────╯ │ │ │ │",
"│ │ │ │ │ │ │ pkg-fmt │ tgz │ │ │ │",
"│ │ │ │ │ │ │ pkg-url │ { repo }/releases/download/{ version }/{ name │ │ │ │",
"│ │ │ │ │ │ │ │ }-{ version }-{ target }.{ archive-format } │ │ │ │",
"│ │ │ │ │ │ ╰───────────┴────────────────────────────────────────────────╯ │ │ │",
"│ │ │ │ ╰──────────┴────────────────────────────────────────────────────────────────╯ │ │",
"│ │ │ name │ nu │ │",
"│ │ │ repository │ https://github.com/nushell/nushell │ │",
"│ │ │ rust-version │ 1.60 │ │",
"│ │ │ version │ 0.74.1 │ │",
"│ │ ╰───────────────┴───────────────────────────────────────────────────────────────────────────────╯ │",
"│ │ ╭───────────┬───────────────────────────────────────────────────────────────────────────────────╮ │",
"│ patch │ │ │ ╭─────────────────┬─────────────────────────────────────────────────────────────╮ │ │",
"│ │ │ crates-io │ │ │ ╭────────┬─────────────────────────────────────────╮ │ │ │",
"│ │ │ │ │ reedline │ │ branch │ main │ │ │ │",
"│ │ │ │ │ │ │ git │ https://github.com/nushell/reedline.git │ │ │ │",
"│ │ │ │ │ │ ╰────────┴─────────────────────────────────────────╯ │ │ │",
"│ │ │ │ ╰─────────────────┴─────────────────────────────────────────────────────────────╯ │ │",
"│ │ ╰───────────┴───────────────────────────────────────────────────────────────────────────────────╯ │",
"│ │ ╭─────────────────────────────────┬─────────────────────────────────────────────────────────────╮ │",
"│ target │ │ │ ╭──────────────┬──────────────────────────────────────────╮ │ │",
"│ │ │ cfg(not(target_os = \"windows\")) │ │ │ ╭────────────────┬─────────────────────╮ │ │ │",
"│ │ │ │ │ dependencies │ │ openssl │ {record 3 fields} │ │ │ │",
"│ │ │ │ │ │ │ signal-hook │ {record 2 fields} │ │ │ │",
"│ │ │ │ │ │ ╰────────────────┴─────────────────────╯ │ │ │",
"│ │ │ │ ╰──────────────┴──────────────────────────────────────────╯ │ │",
"│ │ │ │ ╭──────────────┬──────────────────────────────╮ │ │",
"│ │ │ cfg(target_family = \"unix\") │ │ │ ╭──────┬───────────────────╮ │ │ │",
"│ │ │ │ │ dependencies │ │ atty │ 0.2 │ │ │ │",
"│ │ │ │ │ │ │ nix │ {record 3 fields} │ │ │ │",
"│ │ │ │ │ │ ╰──────┴───────────────────╯ │ │ │",
"│ │ │ │ ╰──────────────┴──────────────────────────────╯ │ │",
"│ │ │ │ ╭────────────────────┬──────────────────╮ │ │",
"│ │ │ cfg(windows) │ │ │ ╭────────┬─────╮ │ │ │",
"│ │ │ │ │ build-dependencies │ │ winres │ 0.1 │ │ │ │",
"│ │ │ │ │ │ ╰────────┴─────╯ │ │ │",
"│ │ │ │ ╰────────────────────┴──────────────────╯ │ │",
"│ │ ╰─────────────────────────────────┴─────────────────────────────────────────────────────────────╯ │",
"│ │ ╭─────────┬─────────────────────────────────────────╮ │",
"│ workspace │ │ │ ╭────┬────────────────────────────────╮ │ │",
"│ │ │ members │ │ 0 │ crates/nu-cli │ │ │",
"│ │ │ │ │ 1 │ crates/nu-engine │ │ │",
"│ │ │ │ │ 2 │ crates/nu-parser │ │ │",
"│ │ │ │ │ 3 │ crates/nu-system │ │ │",
"│ │ │ │ │ 4 │ crates/nu-command │ │ │",
"│ │ │ │ │ 5 │ crates/nu-protocol │ │ │",
"│ │ │ │ │ 6 │ crates/nu-plugin │ │ │",
"│ │ │ │ │ 7 │ crates/nu_plugin_inc │ │ │",
"│ │ │ │ │ 8 │ crates/nu_plugin_gstat │ │ │",
"│ │ │ │ │ 9 │ crates/nu_plugin_example │ │ │",
"│ │ │ │ │ 10 │ crates/nu_plugin_query │ │ │",
"│ │ │ │ │ 11 │ crates/nu_plugin_custom_values │ │ │",
"│ │ │ │ │ 12 │ crates/nu-utils │ │ │",
"│ │ │ │ ╰────┴────────────────────────────────╯ │ │",
"│ │ ╰─────────┴─────────────────────────────────────────╯ │",
"╰──────────────────┴───────────────────────────────────────────────────────────────────────────────────────────────────╯",
]);
assert_eq!(actual.out, expected);
let actual = nu!(
cwd: dirs.test(), pipeline(
"open sample.toml | table --expand --width=60"
));
_print_lines(&actual.out, 60);
let expected = join_lines([
"╭──────────────────┬───────────────────────────────────────╮",
"│ │ ╭───┬─────────┬────────────╮ │",
"│ bench │ │ # │ harness │ name │ │",
"│ │ ├───┼─────────┼────────────┤ │",
"│ │ │ 0 │ false │ benchmarks │ │",
"│ │ ╰───┴─────────┴────────────╯ │",
"│ │ ╭───┬──────┬─────────────╮ │",
"│ bin │ │ # │ name │ path │ │",
"│ │ ├───┼──────┼─────────────┤ │",
"│ │ │ 0 │ nu │ src/main.rs │ │",
"│ │ ╰───┴──────┴─────────────╯ │",
"│ │ ╭───────────────┬───────────────────╮ │",
"│ dependencies │ │ │ ╭──────────┬────╮ │ │",
"│ │ │ chrono │ │ features │ [l │ │ │",
"│ │ │ │ │ │ is │ │ │",
"│ │ │ │ │ │ t │ │ │",
"│ │ │ │ │ │ 1 │ │ │",
"│ │ │ │ │ │ it │ │ │",
"│ │ │ │ │ │ em │ │ │",
"│ │ │ │ │ │ ] │ │ │",
"│ │ │ │ │ version │ 0. │ │ │",
"│ │ │ │ │ │ 4. │ │ │",
"│ │ │ │ │ │ 23 │ │ │",
"│ │ │ │ ╰──────────┴────╯ │ │",
"│ │ │ crossterm │ 0.24.0 │ │",
"│ │ │ ctrlc │ 3.2.1 │ │",
"│ │ │ is_executable │ 1.0.1 │ │",
"│ │ │ log │ 0.4 │ │",
"│ │ │ │ ╭──────────┬────╮ │ │",
"│ │ │ miette │ │ features │ [l │ │ │",
"│ │ │ │ │ │ is │ │ │",
"│ │ │ │ │ │ t │ │ │",
"│ │ │ │ │ │ 1 │ │ │",
"│ │ │ │ │ │ it │ │ │",
"│ │ │ │ │ │ em │ │ │",
"│ │ │ │ │ │ ] │ │ │",
"│ │ │ │ │ version │ 5. │ │ │",
"│ │ │ │ │ │ 5. │ │ │",
"│ │ │ │ │ │ 0 │ │ │",
"│ │ │ │ ╰──────────┴────╯ │ │",
"│ │ │ nu-ansi-term │ 0.46.0 │ │",
"│ │ │ │ ╭─────────┬─────╮ │ │",
"│ │ │ nu-cli │ │ path │ ./c │ │ │",
"│ │ │ │ │ │ rat │ │ │",
"│ │ │ │ │ │ es/ │ │ │",
"│ │ │ │ │ │ nu- │ │ │",
"│ │ │ │ │ │ cli │ │ │",
"│ │ │ │ │ version │ 0.7 │ │ │",
"│ │ │ │ │ │ 4.1 │ │ │",
"│ │ │ │ ╰─────────┴─────╯ │ │",
"│ │ │ │ ╭─────────┬─────╮ │ │",
"│ │ │ nu-engine │ │ path │ ./c │ │ │",
"│ │ │ │ │ │ rat │ │ │",
"│ │ │ │ │ │ es/ │ │ │",
"│ │ │ │ │ │ nu- │ │ │",
"│ │ │ │ │ │ eng │ │ │",
"│ │ │ │ │ │ ine │ │ │",
"│ │ │ │ │ version │ 0.7 │ │ │",
"│ │ │ │ │ │ 4.1 │ │ │",
"│ │ │ │ ╰─────────┴─────╯ │ │",
"│ │ │ rayon │ 1.6.1 │ │",
"│ │ │ │ ╭──────────┬────╮ │ │",
"│ │ │ reedline │ │ features │ [l │ │ │",
"│ │ │ │ │ │ is │ │ │",
"│ │ │ │ │ │ t │ │ │",
"│ │ │ │ │ │ 2 │ │ │",
"│ │ │ │ │ │ it │ │ │",
"│ │ │ │ │ │ em │ │ │",
"│ │ │ │ │ │ s] │ │ │",
"│ │ │ │ │ version │ 0. │ │ │",
"│ │ │ │ │ │ 14 │ │ │",
"│ │ │ │ │ │ .0 │ │ │",
"│ │ │ │ ╰──────────┴────╯ │ │",
"│ │ │ simplelog │ 0.12.0 │ │",
"│ │ │ time │ 0.3.12 │ │",
"│ │ ╰───────────────┴───────────────────╯ │",
"│ │ ╭───────────────────┬───────────────╮ │",
"│ dev-dependencies │ │ assert_cmd │ 2.0.2 │ │",
"│ │ │ criterion │ 0.4 │ │",
"│ │ │ hamcrest2 │ 0.3.0 │ │",
"│ │ │ itertools │ 0.10.3 │ │",
"│ │ │ nu-test-support │ {record 2 │ │",
"│ │ │ │ fields} │ │",
"│ │ │ pretty_assertions │ 1.0.0 │ │",
"│ │ │ rstest │ {record 2 │ │",
"│ │ │ │ fields} │ │",
"│ │ │ serial_test │ 0.10.0 │ │",
"│ │ │ tempfile │ 3.2.0 │ │",
"│ │ ╰───────────────────┴───────────────╯ │",
"│ │ ╭─────────────────────┬─────────────╮ │",
"│ features │ │ │ ╭───┬─────╮ │ │",
"│ │ │ default │ │ 0 │ plu │ │ │",
"│ │ │ │ │ │ gin │ │ │",
"│ │ │ │ │ 1 │ whi │ │ │",
"│ │ │ │ │ │ ch- │ │ │",
"│ │ │ │ │ │ sup │ │ │",
"│ │ │ │ │ │ por │ │ │",
"│ │ │ │ │ │ t │ │ │",
"│ │ │ │ │ 2 │ tra │ │ │",
"│ │ │ │ │ │ sh- │ │ │",
"│ │ │ │ │ │ sup │ │ │",
"│ │ │ │ │ │ por │ │ │",
"│ │ │ │ │ │ t │ │ │",
"│ │ │ │ │ 3 │ sql │ │ │",
"│ │ │ │ │ │ ite │ │ │",
"│ │ │ │ ╰───┴─────╯ │ │",
"│ │ │ │ ╭───┬─────╮ │ │",
"│ │ │ extra │ │ 0 │ def │ │ │",
"│ │ │ │ │ │ aul │ │ │",
"│ │ │ │ │ │ t │ │ │",
"│ │ │ │ ╰───┴─────╯ │ │",
"│ │ │ │ ╭───┬─────╮ │ │",
"│ │ │ plugin │ │ 0 │ nu- │ │ │",
"│ │ │ │ │ │ plu │ │ │",
"│ │ │ │ │ │ gin │ │ │",
"│ │ │ │ │ 1 │ nu- │ │ │",
"│ │ │ │ │ │ cli │ │ │",
"│ │ │ │ │ │ /pl │ │ │",
"│ │ │ │ │ │ ugi │ │ │",
"│ │ │ │ │ │ n │ │ │",
"│ │ │ │ │ 2 │ nu- │ │ │",
"│ │ │ │ │ │ par │ │ │",
"│ │ │ │ │ │ ser │ │ │",
"│ │ │ │ │ │ /pl │ │ │",
"│ │ │ │ │ │ ugi │ │ │",
"│ │ │ │ │ │ n │ │ │",
"│ │ │ │ │ 3 │ nu- │ │ │",
"│ │ │ │ │ │ com │ │ │",
"│ │ │ │ │ │ man │ │ │",
"│ │ │ │ │ │ d/p │ │ │",
"│ │ │ │ │ │ lug │ │ │",
"│ │ │ │ │ │ in │ │ │",
"│ │ │ │ │ 4 │ nu- │ │ │",
"│ │ │ │ │ │ pro │ │ │",
"│ │ │ │ │ │ toc │ │ │",
"│ │ │ │ │ │ ol/ │ │ │",
"│ │ │ │ │ │ plu │ │ │",
"│ │ │ │ │ │ gin │ │ │",
"│ │ │ │ │ 5 │ nu- │ │ │",
"│ │ │ │ │ │ eng │ │ │",
"│ │ │ │ │ │ ine │ │ │",
"│ │ │ │ │ │ /pl │ │ │",
"│ │ │ │ │ │ ugi │ │ │",
"│ │ │ │ │ │ n │ │ │",
"│ │ │ │ ╰───┴─────╯ │ │",
"│ │ │ │ ╭───┬─────╮ │ │",
"│ │ │ stable │ │ 0 │ def │ │ │",
"│ │ │ │ │ │ aul │ │ │",
"│ │ │ │ │ │ t │ │ │",
"│ │ │ │ ╰───┴─────╯ │ │",
"│ │ │ │ ╭───┬─────╮ │ │",
"│ │ │ static-link-openssl │ │ 0 │ dep │ │ │",
"│ │ │ │ │ │ :op │ │ │",
"│ │ │ │ │ │ ens │ │ │",
"│ │ │ │ │ │ sl │ │ │",
"│ │ │ │ ╰───┴─────╯ │ │",
"│ │ │ │ ╭───┬─────╮ │ │",
"│ │ │ trash-support │ │ 0 │ nu- │ │ │",
"│ │ │ │ │ │ com │ │ │",
"│ │ │ │ │ │ man │ │ │",
"│ │ │ │ │ │ d/t │ │ │",
"│ │ │ │ │ │ ras │ │ │",
"│ │ │ │ │ │ h-s │ │ │",
"│ │ │ │ │ │ upp │ │ │",
"│ │ │ │ │ │ ort │ │ │",
"│ │ │ │ ╰───┴─────╯ │ │",
"│ │ │ wasi │ [list 0 │ │",
"│ │ │ │ items] │ │",
"│ │ │ │ ╭───┬─────╮ │ │",
"│ │ │ which-support │ │ 0 │ nu- │ │ │",
"│ │ │ │ │ │ com │ │ │",
"│ │ │ │ │ │ man │ │ │",
"│ │ │ │ │ │ d/w │ │ │",
"│ │ │ │ │ │ hic │ │ │",
"│ │ │ │ │ │ h-s │ │ │",
"│ │ │ │ │ │ upp │ │ │",
"│ │ │ │ │ │ ort │ │ │",
"│ │ │ │ ╰───┴─────╯ │ │",
"│ │ ╰─────────────────────┴─────────────╯ │",
"│ │ ╭───────────────┬───────────────────╮ │",
"│ package │ │ │ ╭───┬───────────╮ │ │",
"│ │ │ authors │ │ 0 │ The │ │ │",
"│ │ │ │ │ │ Nushell │ │ │",
"│ │ │ │ │ │ Project │ │ │",
"│ │ │ │ │ │ Developer │ │ │",
"│ │ │ │ │ │ s │ │ │",
"│ │ │ │ ╰───┴───────────╯ │ │",
"│ │ │ default-run │ nu │ │",
"│ │ │ description │ A new type of │ │",
"│ │ │ │ shell │ │",
"│ │ │ documentation │ https://www.nushe │ │",
"│ │ │ │ ll.sh/book/ │ │",
"│ │ │ edition │ 2021 │ │",
"│ │ │ │ ╭───┬────────╮ │ │",
"│ │ │ exclude │ │ 0 │ images │ │ │",
"│ │ │ │ ╰───┴────────╯ │ │",
"│ │ │ homepage │ https://www.nushe │ │",
"│ │ │ │ ll.sh │ │",
"│ │ │ license │ MIT │ │",
"│ │ │ │ ╭──────────┬────╮ │ │",
"│ │ │ metadata │ │ binstall │ {r │ │ │",
"│ │ │ │ │ │ ec │ │ │",
"│ │ │ │ │ │ or │ │ │",
"│ │ │ │ │ │ d │ │ │",
"│ │ │ │ │ │ 3 │ │ │",
"│ │ │ │ │ │ fi │ │ │",
"│ │ │ │ │ │ el │ │ │",
"│ │ │ │ │ │ ds │ │ │",
"│ │ │ │ │ │ } │ │ │",
"│ │ │ │ ╰──────────┴────╯ │ │",
"│ │ │ name │ nu │ │",
"│ │ │ repository │ https://github.co │ │",
"│ │ │ │ m/nushell/nushell │ │",
"│ │ │ rust-version │ 1.60 │ │",
"│ │ │ version │ 0.74.1 │ │",
"│ │ ╰───────────────┴───────────────────╯ │",
"│ │ ╭───────────┬───────────────────────╮ │",
"│ patch │ │ │ ╭──────────┬────────╮ │ │",
"│ │ │ crates-io │ │ reedline │ {recor │ │ │",
"│ │ │ │ │ │ d 2 │ │ │",
"│ │ │ │ │ │ fields │ │ │",
"│ │ │ │ │ │ } │ │ │",
"│ │ │ │ ╰──────────┴────────╯ │ │",
"│ │ ╰───────────┴───────────────────────╯ │",
"│ target │ {record 3 fields} │",
"│ │ ╭─────────┬─────────────────────────╮ │",
"│ workspace │ │ │ ╭────┬────────────────╮ │ │",
"│ │ │ members │ │ 0 │ crates/nu-cli │ │ │",
"│ │ │ │ │ 1 │ crates/nu-engi │ │ │",
"│ │ │ │ │ │ ne │ │ │",
"│ │ │ │ │ 2 │ crates/nu-pars │ │ │",
"│ │ │ │ │ │ er │ │ │",
"│ │ │ │ │ 3 │ crates/nu-syst │ │ │",
"│ │ │ │ │ │ em │ │ │",
"│ │ │ │ │ 4 │ crates/nu-comm │ │ │",
"│ │ │ │ │ │ and │ │ │",
"│ │ │ │ │ 5 │ crates/nu-prot │ │ │",
"│ │ │ │ │ │ ocol │ │ │",
"│ │ │ │ │ 6 │ crates/nu-plug │ │ │",
"│ │ │ │ │ │ in │ │ │",
"│ │ │ │ │ 7 │ crates/nu_plug │ │ │",
"│ │ │ │ │ │ in_inc │ │ │",
"│ │ │ │ │ 8 │ crates/nu_plug │ │ │",
"│ │ │ │ │ │ in_gstat │ │ │",
"│ │ │ │ │ 9 │ crates/nu_plug │ │ │",
"│ │ │ │ │ │ in_example │ │ │",
"│ │ │ │ │ 10 │ crates/nu_plug │ │ │",
"│ │ │ │ │ │ in_query │ │ │",
"│ │ │ │ │ 11 │ crates/nu_plug │ │ │",
"│ │ │ │ │ │ in_custom_valu │ │ │",
"│ │ │ │ │ │ es │ │ │",
"│ │ │ │ │ 12 │ crates/nu-util │ │ │",
"│ │ │ │ │ │ s │ │ │",
"│ │ │ │ ╰────┴────────────────╯ │ │",
"│ │ ╰─────────┴─────────────────────────╯ │",
"╰──────────────────┴───────────────────────────────────────╯",
]);
assert_eq!(actual.out, expected);
let actual = nu!(
cwd: dirs.test(), pipeline(
"open sample.toml | table --expand --width=40"
));
_print_lines(&actual.out, 40);
let expected = join_lines([
"╭──────────────────┬───────────────────╮",
"│ bench │ [table 1 row] │",
"│ bin │ [table 1 row] │",
"│ dependencies │ {record 13 │",
"│ │ fields} │",
"│ dev-dependencies │ {record 9 fields} │",
"│ features │ {record 8 fields} │",
"│ package │ {record 13 │",
"│ │ fields} │",
"│ │ ╭───────────┬───╮ │",
"│ patch │ │ crates-io │ { │ │",
"│ │ │ │ r │ │",
"│ │ │ │ e │ │",
"│ │ │ │ c │ │",
"│ │ │ │ o │ │",
"│ │ │ │ r │ │",
"│ │ │ │ d │ │",
"│ │ │ │ │ │",
"│ │ │ │ 1 │ │",
"│ │ │ │ │ │",
"│ │ │ │ f │ │",
"│ │ │ │ i │ │",
"│ │ │ │ e │ │",
"│ │ │ │ l │ │",
"│ │ │ │ d │ │",
"│ │ │ │ } │ │",
"│ │ ╰───────────┴───╯ │",
"│ target │ {record 3 fields} │",
"│ workspace │ {record 1 field} │",
"╰──────────────────┴───────────────────╯",
]);
assert_eq!(actual.out, expected);
})
}
fn join_lines(lines: impl IntoIterator<Item = impl AsRef<str>>) -> String {
lines
.into_iter()
.map(|s| s.as_ref().to_string())
.collect::<Vec<_>>()
.join("")
}
// util function to easier copy && paste
fn _print_lines(s: &str, w: usize) {
eprintln!("{:#?}", _split_str_by_width(s, w));
}
// util function to easier copy && paste
// todo: make UTF-8 friendly
fn _split_str_by_width(s: &str, w: usize) -> Vec<String> {
let mut lines = vec![];
let mut line = String::new();
let mut i = 0;
for c in s.chars() {
if i < w {
i += 1;
line.push(c);
} else {
lines.push(line);
line = String::new();
line.push(c);
i = 1;
}
}
lines.push(line);
lines
}