nushell/crates/nu-command/src/commands
Andrés N. Robalino 803826cdcd
90 degree table rotations (clockwise and counter-clockwise) (#3086)
Also for 180 degree is expected. Rotation is not exactly like pivoting (transposing)
for instance, given the following table:

```
> echo [[col1, col2, col3]; [cell1, cell2, cell3] [cell4, cell5, cell6]]
───┬───────┬───────┬───────
 # │ col1  │ col2  │ col3
───┼───────┼───────┼───────
 0 │ cell1 │ cell2 │ cell3
 1 │ cell4 │ cell5 │ cell6
───┴───────┴───────┴───────
```

To rotate it counter clockwise by 90 degrees, we can resort to first transposing (`pivot`)
them adding a new column (preferably integers), sort by that column from highest to lowest,
then remove the column and we have a counter clockwise rotation.

```
> echo [[col1, col2, col3]; [cell1, cell2, cell3] [cell4, cell5, cell6]] | pivot | each --numbered { = $it.item | insert idx $it.index } | sort-by idx | reverse | reject idx
───┬─────────┬─────────┬─────────
 # │ Column0 │ Column1 │ Column2
───┼─────────┼─────────┼─────────
 0 │ col3    │ cell3   │ cell6
 1 │ col2    │ cell2   │ cell5
 2 │ col1    │ cell1   │ cell4
───┴─────────┴─────────┴─────────
```

Which we can get easily, in this case, by doing:

```
> echo [[col1, col2, cel3]; [cell1, cell2, cell3] [cell4, cell5, cell6]] | rotate counter-clockwise
───┬─────────┬─────────┬─────────
 # │ Column0 │ Column1 │ Column2
───┼─────────┼─────────┼─────────
 0 │ col3    │ cell3   │ cell6
 1 │ col2    │ cell2   │ cell5
 2 │ col1    │ cell1   │ cell4
───┴─────────┴─────────┴─────────
```

There are also many powerful use cases with rotation, it makes a breeze creating tables with many columns, say:

```
echo 0..12 | rotate counter-clockwise | reject Column0
───┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬──────────┬──────────┬──────────┬──────────
 # │ Column1 │ Column2 │ Column3 │ Column4 │ Column5 │ Column6 │ Column7 │ Column8 │ Column9 │ Column10 │ Column11 │ Column12 │ Column13
───┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼──────────┼──────────┼──────────┼──────────
 0 │       0 │       1 │       2 │       3 │       4 │       5 │       6 │       7 │       8 │        9 │       10 │       11 │       12
───┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴──────────┴──────────┴──────────┴──────────
```
2021-02-22 06:56:34 -05:00
..
autoview Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
classified Replace dirs and directories with maintained (#2949) 2021-01-19 14:24:27 -06:00
config nu-cli refactor moving commands into their own crate nu-command (#2910) 2021-01-12 17:59:53 +13:00
date Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
each Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
format Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
hash_ Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
keep Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
math Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
move_ Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
nu Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
parse Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
path Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
random Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
rotate 90 degree table rotations (clockwise and counter-clockwise) (#3086) 2021-02-22 06:56:34 -05:00
skip Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
split Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
str_ Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
table Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
url_ Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
ansi.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
append.rs nu-cli refactor moving commands into their own crate nu-command (#2910) 2021-01-12 17:59:53 +13:00
args.rs nu-cli refactor moving commands into their own crate nu-command (#2910) 2021-01-12 17:59:53 +13:00
autoenv.rs Extract .nu-env tests and more granularity (#3078) 2021-02-18 20:24:27 -05:00
autoenv_trust.rs nu-cli refactor moving commands into their own crate nu-command (#2910) 2021-01-12 17:59:53 +13:00
autoenv_untrust.rs nu-cli refactor moving commands into their own crate nu-command (#2910) 2021-01-12 17:59:53 +13:00
benchmark.rs Ensure selection of columns are done once per column (#3012) 2021-02-05 19:34:26 -05:00
build_string.rs nu-cli refactor moving commands into their own crate nu-command (#2910) 2021-01-12 17:59:53 +13:00
cal.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
cd.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
char_.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
chart.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
clear.rs nu-cli refactor moving commands into their own crate nu-command (#2910) 2021-01-12 17:59:53 +13:00
clip.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
command.rs nu-cli refactor moving commands into their own crate nu-command (#2910) 2021-01-12 17:59:53 +13:00
compact.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
constants.rs nu-cli refactor moving commands into their own crate nu-command (#2910) 2021-01-12 17:59:53 +13:00
count.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
cp.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
debug.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
def.rs nu-cli refactor moving commands into their own crate nu-command (#2910) 2021-01-12 17:59:53 +13:00
default.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
default_context.rs 90 degree table rotations (clockwise and counter-clockwise) (#3086) 2021-02-22 06:56:34 -05:00
describe.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
do_.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
drop.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
du.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
echo.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
empty.rs Ensure selection of columns are done once per column (#3012) 2021-02-05 19:34:26 -05:00
enter.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
every.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
exec.rs nu-cli refactor moving commands into their own crate nu-command (#2910) 2021-01-12 17:59:53 +13:00
exit.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
first.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
flatten.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
from.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
from_csv.rs add "-0" as short for --headerless in "from" commands (#3042) 2021-02-22 20:25:17 +13:00
from_delimited_data.rs add "-0" as short for --headerless in "from" commands (#3042) 2021-02-22 20:25:17 +13:00
from_eml.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
from_ics.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
from_ini.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
from_json.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
from_ods.rs add "-0" as short for --headerless in "from" commands (#3042) 2021-02-22 20:25:17 +13:00
from_ssv.rs add "-0" as short for --headerless in "from" commands (#3042) 2021-02-22 20:25:17 +13:00
from_toml.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
from_tsv.rs add "-0" as short for --headerless in "from" commands (#3042) 2021-02-22 20:25:17 +13:00
from_url.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
from_vcf.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
from_xlsx.rs add "-0" as short for --headerless in "from" commands (#3042) 2021-02-22 20:25:17 +13:00
from_xml.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
from_yaml.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
get.rs Soft rest arguments column path cohersions. (#3016) 2021-02-06 20:05:47 -05:00
group_by.rs Ensure selection of columns are done once per column (#3012) 2021-02-05 19:34:26 -05:00
group_by_date.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
headers.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
help.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
histogram.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
history.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
if_.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
insert.rs Ensure selection of columns are done once per column (#3012) 2021-02-05 19:34:26 -05:00
into_int.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
kill.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
last.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
let_.rs nu-cli refactor moving commands into their own crate nu-command (#2910) 2021-01-12 17:59:53 +13:00
let_env.rs nu-cli refactor moving commands into their own crate nu-command (#2910) 2021-01-12 17:59:53 +13:00
lines.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
ls.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
macros.rs nu-cli refactor moving commands into their own crate nu-command (#2910) 2021-01-12 17:59:53 +13:00
merge.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
mkdir.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
next.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
nth.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
open.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
pivot.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
prepend.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
prev.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
pwd.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
range.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
reduce.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
reject.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
rename.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
reverse.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
rm.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
run_external.rs nu-cli refactor moving commands into their own crate nu-command (#2910) 2021-01-12 17:59:53 +13:00
save.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
select.rs Soft rest arguments column path cohersions. (#3016) 2021-02-06 20:05:47 -05:00
seq.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
seq_dates.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
shells.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
shuffle.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
size.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
sleep.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
sort_by.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
source.rs Source path including tilda (#3059) 2021-02-15 21:41:49 +13:00
split_by.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
tags.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
termsize.rs change help text (#3054) 2021-02-13 13:20:34 -06:00
to.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
to_csv.rs add "-0" as short for --headerless in "from" commands (#3042) 2021-02-22 20:25:17 +13:00
to_delimited_data.rs add "-0" as short for --headerless in "from" commands (#3042) 2021-02-22 20:25:17 +13:00
to_html.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
to_json.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
to_md.rs Minimal markdown syntax per element support. (#2997) 2021-02-02 12:09:19 -05:00
to_toml.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
to_tsv.rs add "-0" as short for --headerless in "from" commands (#3042) 2021-02-22 20:25:17 +13:00
to_url.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
to_xml.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
to_yaml.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
touch.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
uniq.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
update.rs Ensure selection of columns are done once per column (#3012) 2021-02-05 19:34:26 -05:00
version.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
where_.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
which_.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
with_env.rs Keep the environment properly set. (#3072) 2021-02-18 15:56:14 +13:00
wrap.rs Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00