2022-03-17 23:35:50 +01:00
|
|
|
mod alias;
|
2021-04-03 20:40:54 +02:00
|
|
|
mod all;
|
|
|
|
mod any;
|
2019-12-15 17:15:06 +01:00
|
|
|
mod append;
|
New commands: `break`, `continue`, `return`, and `loop` (#7230)
# Description
This adds `break`, `continue`, `return`, and `loop`.
* `break` - breaks out a loop
* `continue` - continues a loop at the next iteration
* `return` - early return from a function call
* `loop` - loop forever (until the loop hits a break)
Examples:
```
for i in 1..10 {
if $i == 5 {
continue
}
print $i
}
```
```
for i in 1..10 {
if $i == 5 {
break
}
print $i
}
```
```
def foo [x] {
if true {
return 2
}
$x
}
foo 100
```
```
loop { print "hello, forever" }
```
```
[1, 2, 3, 4, 5] | each {|x|
if $x > 3 { break }
$x
}
```
# User-Facing Changes
Adds the above commands.
# Tests + Formatting
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
# After Submitting
If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
2022-11-24 21:39:16 +01:00
|
|
|
mod break_;
|
2020-05-10 01:05:48 +02:00
|
|
|
mod cal;
|
2019-12-15 17:15:06 +01:00
|
|
|
mod cd;
|
|
|
|
mod compact;
|
New commands: `break`, `continue`, `return`, and `loop` (#7230)
# Description
This adds `break`, `continue`, `return`, and `loop`.
* `break` - breaks out a loop
* `continue` - continues a loop at the next iteration
* `return` - early return from a function call
* `loop` - loop forever (until the loop hits a break)
Examples:
```
for i in 1..10 {
if $i == 5 {
continue
}
print $i
}
```
```
for i in 1..10 {
if $i == 5 {
break
}
print $i
}
```
```
def foo [x] {
if true {
return 2
}
$x
}
foo 100
```
```
loop { print "hello, forever" }
```
```
[1, 2, 3, 4, 5] | each {|x|
if $x > 3 { break }
$x
}
```
# User-Facing Changes
Adds the above commands.
# Tests + Formatting
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
# After Submitting
If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
2022-11-24 21:39:16 +01:00
|
|
|
mod continue_;
|
2019-12-15 17:15:06 +01:00
|
|
|
mod cp;
|
2022-05-23 18:59:34 +02:00
|
|
|
mod date;
|
2021-01-07 18:14:51 +01:00
|
|
|
mod def;
|
2019-12-15 17:15:06 +01:00
|
|
|
mod default;
|
2022-06-30 03:01:34 +02:00
|
|
|
mod do_;
|
2020-04-26 08:34:45 +02:00
|
|
|
mod drop;
|
2020-04-13 09:59:57 +02:00
|
|
|
mod each;
|
2020-07-06 10:23:27 +02:00
|
|
|
mod echo;
|
2020-10-06 12:21:20 +02:00
|
|
|
mod empty;
|
2019-12-15 17:15:06 +01:00
|
|
|
mod enter;
|
2022-07-12 13:03:50 +02:00
|
|
|
mod error_make;
|
2020-06-16 21:58:41 +02:00
|
|
|
mod every;
|
2022-08-02 17:26:16 +02:00
|
|
|
mod export_def;
|
2021-08-27 10:48:41 +02:00
|
|
|
mod find;
|
2019-12-15 17:15:06 +01:00
|
|
|
mod first;
|
2020-10-14 11:36:11 +02:00
|
|
|
mod flatten;
|
2019-12-15 17:15:06 +01:00
|
|
|
mod format;
|
2022-08-06 14:09:14 +02:00
|
|
|
mod g;
|
2019-12-15 17:15:06 +01:00
|
|
|
mod get;
|
2022-10-15 18:00:38 +02:00
|
|
|
mod glob;
|
2019-12-15 17:15:06 +01:00
|
|
|
mod group_by;
|
2020-11-30 18:47:35 +01:00
|
|
|
mod hash_;
|
2020-03-29 04:05:57 +02:00
|
|
|
mod headers;
|
2021-02-26 21:05:22 +01:00
|
|
|
mod help;
|
2019-12-15 17:15:06 +01:00
|
|
|
mod histogram;
|
2022-03-17 18:55:02 +01:00
|
|
|
mod insert;
|
2021-09-03 01:19:54 +02:00
|
|
|
mod into_filesize;
|
2020-08-27 07:44:18 +02:00
|
|
|
mod into_int;
|
2019-12-15 17:15:06 +01:00
|
|
|
mod last;
|
2021-03-13 22:46:40 +01:00
|
|
|
mod length;
|
2022-06-24 23:55:25 +02:00
|
|
|
mod let_;
|
2019-12-15 17:15:06 +01:00
|
|
|
mod lines;
|
|
|
|
mod ls;
|
2020-04-18 03:50:58 +02:00
|
|
|
mod math;
|
2020-04-30 06:18:24 +02:00
|
|
|
mod merge;
|
2019-12-15 17:15:06 +01:00
|
|
|
mod mkdir;
|
2020-07-06 17:27:01 +02:00
|
|
|
mod move_;
|
2022-11-11 07:51:08 +01:00
|
|
|
mod mut_;
|
2022-08-07 20:30:40 +02:00
|
|
|
mod n;
|
2022-06-22 05:27:58 +02:00
|
|
|
mod network;
|
2022-06-26 13:53:06 +02:00
|
|
|
mod nu_check;
|
2022-02-04 03:01:45 +01:00
|
|
|
mod open;
|
2022-08-07 20:30:40 +02:00
|
|
|
mod p;
|
2022-02-04 03:01:45 +01:00
|
|
|
mod parse;
|
|
|
|
mod path;
|
2022-08-18 18:58:51 +02:00
|
|
|
mod platform;
|
2019-12-15 17:15:06 +01:00
|
|
|
mod prepend;
|
2022-07-02 16:54:49 +02:00
|
|
|
mod print;
|
2022-11-23 01:58:11 +01:00
|
|
|
#[cfg(feature = "sqlite")]
|
2022-04-20 06:58:21 +02:00
|
|
|
mod query;
|
2020-06-25 07:51:09 +02:00
|
|
|
mod random;
|
2019-12-15 17:15:06 +01:00
|
|
|
mod range;
|
2022-11-22 19:26:13 +01:00
|
|
|
mod redirection;
|
2020-08-04 19:16:19 +02:00
|
|
|
mod reduce;
|
2022-02-08 21:57:46 +01:00
|
|
|
mod reject;
|
2020-03-03 22:01:24 +01:00
|
|
|
mod rename;
|
New commands: `break`, `continue`, `return`, and `loop` (#7230)
# Description
This adds `break`, `continue`, `return`, and `loop`.
* `break` - breaks out a loop
* `continue` - continues a loop at the next iteration
* `return` - early return from a function call
* `loop` - loop forever (until the loop hits a break)
Examples:
```
for i in 1..10 {
if $i == 5 {
continue
}
print $i
}
```
```
for i in 1..10 {
if $i == 5 {
break
}
print $i
}
```
```
def foo [x] {
if true {
return 2
}
$x
}
foo 100
```
```
loop { print "hello, forever" }
```
```
[1, 2, 3, 4, 5] | each {|x|
if $x > 3 { break }
$x
}
```
# User-Facing Changes
Adds the above commands.
# Tests + Formatting
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
# After Submitting
If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
2022-11-24 21:39:16 +01:00
|
|
|
mod return_;
|
2019-12-15 17:15:06 +01:00
|
|
|
mod reverse;
|
|
|
|
mod rm;
|
2021-02-23 19:29:07 +01:00
|
|
|
mod roll;
|
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 12:56:34 +01:00
|
|
|
mod rotate;
|
2022-03-08 02:17:33 +01:00
|
|
|
mod run_external;
|
2019-12-15 17:15:06 +01:00
|
|
|
mod save;
|
2020-05-07 13:03:43 +02:00
|
|
|
mod select;
|
2020-04-20 08:41:51 +02:00
|
|
|
mod semicolon;
|
2022-11-10 02:06:47 +01:00
|
|
|
mod seq_char;
|
2022-08-08 13:31:24 +02:00
|
|
|
mod shells;
|
2020-07-15 03:44:49 +02:00
|
|
|
mod skip;
|
2022-12-01 14:11:30 +01:00
|
|
|
mod sort;
|
2019-12-15 17:15:06 +01:00
|
|
|
mod sort_by;
|
2022-08-31 22:32:56 +02:00
|
|
|
mod source_env;
|
2019-12-15 17:15:06 +01:00
|
|
|
mod split_by;
|
|
|
|
mod split_column;
|
2020-05-24 08:41:30 +02:00
|
|
|
mod split_row;
|
2020-05-27 00:19:18 +02:00
|
|
|
mod str_;
|
2022-10-03 18:40:16 +02:00
|
|
|
mod table;
|
2022-04-07 22:49:28 +02:00
|
|
|
mod take;
|
2020-02-18 21:54:32 +01:00
|
|
|
mod touch;
|
2022-06-23 02:19:06 +02:00
|
|
|
mod transpose;
|
2022-11-24 05:52:11 +01:00
|
|
|
mod try_;
|
2019-12-31 05:05:02 +01:00
|
|
|
mod uniq;
|
2022-12-02 11:36:01 +01:00
|
|
|
mod uniq_by;
|
2020-05-07 07:33:30 +02:00
|
|
|
mod update;
|
2022-03-17 18:55:02 +01:00
|
|
|
mod upsert;
|
2022-11-19 19:14:29 +01:00
|
|
|
mod url;
|
2022-02-18 02:58:24 +01:00
|
|
|
mod use_;
|
2019-12-15 17:15:06 +01:00
|
|
|
mod where_;
|
2022-03-29 13:10:43 +02:00
|
|
|
#[cfg(feature = "which-support")]
|
2021-01-08 18:44:31 +01:00
|
|
|
mod which;
|
2022-11-11 19:21:45 +01:00
|
|
|
mod while_;
|
2020-05-06 05:56:31 +02:00
|
|
|
mod with_env;
|
2019-12-15 17:15:06 +01:00
|
|
|
mod wrap;
|
2021-08-15 06:36:08 +02:00
|
|
|
mod zip;
|