nushell/crates/nu-cmd-lang/src/core_commands
JT 5d9e2455f7
Let with pipeline (#9589)
# Description

This changes the default behaviour of `let` to be able to take a
pipeline as its initial value.

For example:

```
> let x = "hello world" | str length
```

This is a change from the existing behaviour, where the right hand side
is assumed to be an expression. Pipelines are more general, and can be
more powerful.

My google foo is failing me, but this also fixes this issue:

```
let x = foo
```

Currently, this reads `foo` as a bareword that gets converted to a
string rather than running the `foo` command. In practice, this is
really annoying and is a really hard to spot bug in a script.

# User-Facing Changes

BREAKING CHANGE BREAKING CHANGE

`let` gains the power to be assigned via a pipeline. However, this
changes the behaviour of `let x = foo` from assigning the string "foo"
to `$x` to being "run the command `foo` and give the result to `$x`"

# 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 -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` to run the tests for the
standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# 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.
-->
2023-07-03 17:45:10 +12:00
..
overlay remove let-env, focus on mutating $env (#9574) 2023-07-01 07:57:51 +12:00
scope split $nu variable into scope commands and simpler $nu (#9487) 2023-06-21 09:33:01 +12:00
alias.rs Uniformize usage() and extra_usage() message ending for commands helper. (#8268) 2023-02-28 21:33:02 -08:00
break_.rs Remove parser keywords label from commands that do not need it (#8780) 2023-04-07 01:12:21 +03:00
collect.rs Move variables to var stack (#8604) 2023-03-25 12:56:45 +13:00
const_.rs Switch let/let-env family to init with math expressions (#8545) 2023-03-23 09:14:10 +13:00
continue_.rs Remove parser keywords label from commands that do not need it (#8780) 2023-04-07 01:12:21 +03:00
def_env.rs remove let-env, focus on mutating $env (#9574) 2023-07-01 07:57:51 +12:00
def.rs Uniformize usage() and extra_usage() message ending for commands helper. (#8268) 2023-02-28 21:33:02 -08:00
describe.rs Cratification: Break out nu_cmd_lang into a separate crate (#8181) 2023-02-24 09:54:42 -06:00
do_.rs Restrict closure expression to be something like {|| ...} (#8290) 2023-03-17 07:36:28 -05:00
echo.rs Cratification: Break out nu_cmd_lang into a separate crate (#8181) 2023-02-24 09:54:42 -06:00
error_make.rs allow records to have type annotations (#8914) 2023-04-26 08:16:55 -05:00
export_alias.rs Uniformize usage() and extra_usage() message ending for commands helper. (#8268) 2023-02-28 21:33:02 -08:00
export_def_env.rs remove let-env, focus on mutating $env (#9574) 2023-07-01 07:57:51 +12:00
export_def.rs Uniformize usage() and extra_usage() message ending for commands helper. (#8268) 2023-02-28 21:33:02 -08:00
export_extern.rs Uniformize usage() and extra_usage() message ending for commands helper. (#8268) 2023-02-28 21:33:02 -08:00
export_module.rs Allow creating modules from directories (#9066) 2023-05-06 21:39:54 +03:00
export_use.rs Uniformize usage() and extra_usage() message ending for commands helper. (#8268) 2023-02-28 21:33:02 -08:00
export.rs Cratification: Break out nu_cmd_lang into a separate crate (#8181) 2023-02-24 09:54:42 -06:00
extern_.rs Add extern def which allows raw arguments (#8956) 2023-04-28 09:06:43 +02:00
for_.rs Remove autoprinting of for loop (#8843) 2023-04-11 05:23:22 +12:00
hide_env.rs remove let-env, focus on mutating $env (#9574) 2023-07-01 07:57:51 +12:00
hide.rs Uniformize usage() and extra_usage() message ending for commands helper. (#8268) 2023-02-28 21:33:02 -08:00
if_.rs Remove parser keywords label from commands that do not need it (#8780) 2023-04-07 01:12:21 +03:00
ignore.rs Uniformize usage() and extra_usage() message ending for commands helper. (#8268) 2023-02-28 21:33:02 -08:00
lazy_make.rs Feature: Userland LazyRecords (#8332) 2023-05-17 18:35:22 -05:00
let_.rs Let with pipeline (#9589) 2023-07-03 17:45:10 +12:00
loop_.rs Remove parser keywords label from commands that do not need it (#8780) 2023-04-07 01:12:21 +03:00
match_.rs Remove parser keywords label from commands that do not need it (#8780) 2023-04-07 01:12:21 +03:00
mod.rs split $nu variable into scope commands and simpler $nu (#9487) 2023-06-21 09:33:01 +12:00
module.rs remove let-env, focus on mutating $env (#9574) 2023-07-01 07:57:51 +12:00
mut_.rs Switch let/let-env family to init with math expressions (#8545) 2023-03-23 09:14:10 +13:00
register.rs Clarify how register works (#8583) 2023-03-23 13:02:22 -05:00
return_.rs Uniformize usage() and extra_usage() message ending for commands helper. (#8268) 2023-02-28 21:33:02 -08:00
try_.rs Remove parser keywords label from commands that do not need it (#8780) 2023-04-07 01:12:21 +03:00
use_.rs Test examples of use (#9032) 2023-06-25 07:43:48 -05:00
version.rs Changes global allocator to mimalloc, improving performance. (#9415) 2023-06-14 17:27:12 -05:00
while_.rs Remove parser keywords label from commands that do not need it (#8780) 2023-04-07 01:12:21 +03:00