forked from extern/nushell
cdc4fb1011
fix `detect columns` with flag `-c, --combine-columns` run failed when using some range - fixes #9653 fix #9653 the cmd detect columns with the flag -c, --combine-columns run failed when using some range. add unit test for the command `detect columns` ```text Attempt to automatically split text into multiple columns. Usage: > detect columns {flags} Flags: -h, --help - Display the help message for this command -s, --skip <Int> - number of rows to skip before detecting -n, --no-headers - don't detect headers -c, --combine-columns <Range> - columns to be combined; listed as a range Signatures: <string> | detect columns -> <table> Examples: Splits string across multiple columns > 'a b c' | detect columns -n ╭───┬─────────┬─────────┬─────────╮ │ # │ column0 │ column1 │ column2 │ ├───┼─────────┼─────────┼─────────┤ │ 0 │ a │ b │ c │ ╰───┴─────────┴─────────┴─────────╯ Splits a multi-line string into columns with headers detected > $'c1 c2 c3 c4 c5(char nl)a b c d e' | detect columns ╭───┬────┬────┬────┬────┬────╮ │ # │ c1 │ c2 │ c3 │ c4 │ c5 │ ├───┼────┼────┼────┼────┼────┤ │ 0 │ a │ b │ c │ d │ e │ ╰───┴────┴────┴────┴────┴────╯ > $'c1 c2 c3 c4 c5(char nl)a b c d e' | detect columns -c 0..1 ╭───┬─────┬────┬────┬────╮ │ # │ c1 │ c3 │ c4 │ c5 │ ├───┼─────┼────┼────┼────┤ │ 0 │ a b │ c │ d │ e │ ╰───┴─────┴────┴────┴────╯ Splits a multi-line string into columns with headers detected > $'c1 c2 c3 c4 c5(char nl)a b c d e' | detect columns -c -2..-1 ╭───┬────┬────┬────┬─────╮ │ # │ c1 │ c2 │ c3 │ c4 │ ├───┼────┼────┼────┼─────┤ │ 0 │ a │ b │ c │ d e │ ╰───┴────┴────┴────┴─────╯ Splits a multi-line string into columns with headers detected > $'c1 c2 c3 c4 c5(char nl)a b c d e' | detect columns -c 2.. ╭───┬────┬────┬───────╮ │ # │ c1 │ c2 │ c3 │ ├───┼────┼────┼───────┤ │ 0 │ a │ b │ c d e │ ╰───┴────┴────┴───────╯ Parse external ls command and combine columns for datetime > ^ls -lh | detect columns --no-headers --skip 1 --combine-columns 5..7 ```
114 lines
1.4 KiB
Rust
114 lines
1.4 KiB
Rust
mod alias;
|
|
mod all;
|
|
mod any;
|
|
mod append;
|
|
mod assignment;
|
|
mod break_;
|
|
mod cal;
|
|
mod cd;
|
|
mod compact;
|
|
mod continue_;
|
|
mod cp;
|
|
mod date;
|
|
mod def;
|
|
mod default;
|
|
mod detect_columns;
|
|
mod do_;
|
|
mod drop;
|
|
mod each;
|
|
mod echo;
|
|
mod empty;
|
|
mod error_make;
|
|
mod every;
|
|
#[cfg(not(windows))]
|
|
mod exec;
|
|
mod export_def;
|
|
mod fill;
|
|
mod find;
|
|
mod first;
|
|
mod flatten;
|
|
mod for_;
|
|
#[cfg(feature = "extra")]
|
|
mod format;
|
|
mod get;
|
|
mod glob;
|
|
mod group_by;
|
|
mod hash_;
|
|
mod headers;
|
|
mod help;
|
|
mod histogram;
|
|
mod insert;
|
|
mod inspect;
|
|
mod into_filesize;
|
|
mod into_int;
|
|
mod join;
|
|
mod last;
|
|
mod length;
|
|
mod let_;
|
|
mod lines;
|
|
mod loop_;
|
|
mod ls;
|
|
mod match_;
|
|
mod math;
|
|
mod merge;
|
|
mod mkdir;
|
|
mod move_;
|
|
mod mut_;
|
|
mod network;
|
|
mod nu_check;
|
|
mod open;
|
|
mod par_each;
|
|
mod parse;
|
|
mod path;
|
|
mod platform;
|
|
mod prepend;
|
|
mod print;
|
|
#[cfg(feature = "sqlite")]
|
|
mod query;
|
|
mod random;
|
|
mod range;
|
|
mod redirection;
|
|
mod reduce;
|
|
mod reject;
|
|
mod rename;
|
|
mod return_;
|
|
mod reverse;
|
|
mod rm;
|
|
#[cfg(feature = "extra")]
|
|
mod roll;
|
|
#[cfg(feature = "extra")]
|
|
mod rotate;
|
|
mod run_external;
|
|
mod save;
|
|
mod select;
|
|
mod semicolon;
|
|
mod seq;
|
|
mod seq_char;
|
|
mod skip;
|
|
mod sort;
|
|
mod sort_by;
|
|
mod source_env;
|
|
mod split_by;
|
|
mod split_column;
|
|
mod split_row;
|
|
mod str_;
|
|
mod table;
|
|
mod take;
|
|
mod to_text;
|
|
mod touch;
|
|
mod transpose;
|
|
mod try_;
|
|
mod uniq;
|
|
mod uniq_by;
|
|
mod update;
|
|
mod upsert;
|
|
mod url;
|
|
mod use_;
|
|
mod where_;
|
|
#[cfg(feature = "which-support")]
|
|
mod which;
|
|
mod while_;
|
|
mod with_env;
|
|
mod wrap;
|
|
mod zip;
|