2022-03-17 22:35:50 +00:00
|
|
|
mod alias;
|
2021-04-03 18:40:54 +00:00
|
|
|
mod all;
|
|
|
|
mod any;
|
2019-12-15 16:15:06 +00:00
|
|
|
mod append;
|
2022-12-09 16:20:58 +00:00
|
|
|
mod assignment;
|
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 20:39:16 +00:00
|
|
|
mod break_;
|
2020-05-09 23:05:48 +00:00
|
|
|
mod cal;
|
2019-12-15 16:15:06 +00: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 20:39:16 +00:00
|
|
|
mod continue_;
|
2019-12-15 16:15:06 +00:00
|
|
|
mod cp;
|
2022-05-23 16:59:34 +00:00
|
|
|
mod date;
|
2021-01-07 17:14:51 +00:00
|
|
|
mod def;
|
2019-12-15 16:15:06 +00:00
|
|
|
mod default;
|
2022-06-30 01:01:34 +00:00
|
|
|
mod do_;
|
2020-04-26 06:34:45 +00:00
|
|
|
mod drop;
|
2020-04-13 07:59:57 +00:00
|
|
|
mod each;
|
2020-07-06 08:23:27 +00:00
|
|
|
mod echo;
|
2020-10-06 10:21:20 +00:00
|
|
|
mod empty;
|
2019-12-15 16:15:06 +00:00
|
|
|
mod enter;
|
2022-07-12 11:03:50 +00:00
|
|
|
mod error_make;
|
2020-06-16 19:58:41 +00:00
|
|
|
mod every;
|
2022-12-21 22:33:26 +00:00
|
|
|
#[cfg(not(windows))]
|
|
|
|
mod exec;
|
2022-08-02 15:26:16 +00:00
|
|
|
mod export_def;
|
2021-08-27 08:48:41 +00:00
|
|
|
mod find;
|
2019-12-15 16:15:06 +00:00
|
|
|
mod first;
|
2020-10-14 09:36:11 +00:00
|
|
|
mod flatten;
|
2022-12-11 16:46:03 +00:00
|
|
|
mod for_;
|
2019-12-15 16:15:06 +00:00
|
|
|
mod format;
|
2022-08-06 12:09:14 +00:00
|
|
|
mod g;
|
2019-12-15 16:15:06 +00:00
|
|
|
mod get;
|
2022-10-15 16:00:38 +00:00
|
|
|
mod glob;
|
2019-12-15 16:15:06 +00:00
|
|
|
mod group_by;
|
2020-11-30 17:47:35 +00:00
|
|
|
mod hash_;
|
2020-03-29 02:05:57 +00:00
|
|
|
mod headers;
|
2021-02-26 20:05:22 +00:00
|
|
|
mod help;
|
2019-12-15 16:15:06 +00:00
|
|
|
mod histogram;
|
2022-03-17 17:55:02 +00:00
|
|
|
mod insert;
|
2021-09-02 23:19:54 +00:00
|
|
|
mod into_filesize;
|
2020-08-27 05:44:18 +00:00
|
|
|
mod into_int;
|
2019-12-15 16:15:06 +00:00
|
|
|
mod last;
|
2021-03-13 21:46:40 +00:00
|
|
|
mod length;
|
2022-06-24 21:55:25 +00:00
|
|
|
mod let_;
|
2019-12-15 16:15:06 +00:00
|
|
|
mod lines;
|
2022-12-11 16:46:03 +00:00
|
|
|
mod loop_;
|
2019-12-15 16:15:06 +00:00
|
|
|
mod ls;
|
2020-04-18 01:50:58 +00:00
|
|
|
mod math;
|
2020-04-30 04:18:24 +00:00
|
|
|
mod merge;
|
2019-12-15 16:15:06 +00:00
|
|
|
mod mkdir;
|
2020-07-06 15:27:01 +00:00
|
|
|
mod move_;
|
2022-11-11 06:51:08 +00:00
|
|
|
mod mut_;
|
2022-08-07 18:30:40 +00:00
|
|
|
mod n;
|
2022-06-22 03:27:58 +00:00
|
|
|
mod network;
|
2022-06-26 11:53:06 +00:00
|
|
|
mod nu_check;
|
2022-02-04 02:01:45 +00:00
|
|
|
mod open;
|
2022-08-07 18:30:40 +00:00
|
|
|
mod p;
|
2022-02-04 02:01:45 +00:00
|
|
|
mod parse;
|
|
|
|
mod path;
|
2022-08-18 16:58:51 +00:00
|
|
|
mod platform;
|
2019-12-15 16:15:06 +00:00
|
|
|
mod prepend;
|
2022-07-02 14:54:49 +00:00
|
|
|
mod print;
|
2022-11-23 00:58:11 +00:00
|
|
|
#[cfg(feature = "sqlite")]
|
2022-04-20 04:58:21 +00:00
|
|
|
mod query;
|
2020-06-25 05:51:09 +00:00
|
|
|
mod random;
|
2019-12-15 16:15:06 +00:00
|
|
|
mod range;
|
2022-11-22 18:26:13 +00:00
|
|
|
mod redirection;
|
2020-08-04 17:16:19 +00:00
|
|
|
mod reduce;
|
2022-02-08 20:57:46 +00:00
|
|
|
mod reject;
|
2020-03-03 21:01:24 +00: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 20:39:16 +00:00
|
|
|
mod return_;
|
2019-12-15 16:15:06 +00:00
|
|
|
mod reverse;
|
|
|
|
mod rm;
|
2021-02-23 18:29:07 +00: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 11:56:34 +00:00
|
|
|
mod rotate;
|
2022-03-08 01:17:33 +00:00
|
|
|
mod run_external;
|
2019-12-15 16:15:06 +00:00
|
|
|
mod save;
|
2020-05-07 11:03:43 +00:00
|
|
|
mod select;
|
2020-04-20 06:41:51 +00:00
|
|
|
mod semicolon;
|
2022-12-07 02:48:03 +00:00
|
|
|
mod seq;
|
2022-11-10 01:06:47 +00:00
|
|
|
mod seq_char;
|
2022-08-08 11:31:24 +00:00
|
|
|
mod shells;
|
2020-07-15 01:44:49 +00:00
|
|
|
mod skip;
|
2022-12-01 13:11:30 +00:00
|
|
|
mod sort;
|
2019-12-15 16:15:06 +00:00
|
|
|
mod sort_by;
|
2022-08-31 20:32:56 +00:00
|
|
|
mod source_env;
|
2019-12-15 16:15:06 +00:00
|
|
|
mod split_by;
|
|
|
|
mod split_column;
|
2020-05-24 06:41:30 +00:00
|
|
|
mod split_row;
|
2020-05-26 22:19:18 +00:00
|
|
|
mod str_;
|
2022-10-03 16:40:16 +00:00
|
|
|
mod table;
|
2022-04-07 20:49:28 +00:00
|
|
|
mod take;
|
2022-12-23 00:38:07 +00:00
|
|
|
mod to_text;
|
2020-02-18 20:54:32 +00:00
|
|
|
mod touch;
|
2022-06-23 00:19:06 +00:00
|
|
|
mod transpose;
|
2022-11-24 04:52:11 +00:00
|
|
|
mod try_;
|
2019-12-31 04:05:02 +00:00
|
|
|
mod uniq;
|
2022-12-02 10:36:01 +00:00
|
|
|
mod uniq_by;
|
2020-05-07 05:33:30 +00:00
|
|
|
mod update;
|
2022-03-17 17:55:02 +00:00
|
|
|
mod upsert;
|
2022-11-19 18:14:29 +00:00
|
|
|
mod url;
|
2022-02-18 01:58:24 +00:00
|
|
|
mod use_;
|
2019-12-15 16:15:06 +00:00
|
|
|
mod where_;
|
2022-03-29 11:10:43 +00:00
|
|
|
#[cfg(feature = "which-support")]
|
2021-01-08 17:44:31 +00:00
|
|
|
mod which;
|
2022-11-11 18:21:45 +00:00
|
|
|
mod while_;
|
2020-05-06 03:56:31 +00:00
|
|
|
mod with_env;
|
2019-12-15 16:15:06 +00:00
|
|
|
mod wrap;
|
2021-08-15 04:36:08 +00:00
|
|
|
mod zip;
|