nushell/crates/nu-command/src
WindSoilder 18fdc5a229
rename: add -b flag to support closure input (#8948)
# Description
Closes: #8108 

Adding a new `-b` flag to `rename` command. I have thought about making
it as a positional argument, but I don't think it's ok because we alredy
have `...rest` parameters

Here are how they works:
```
#  Rename fields based on a given closure
> {a: 1, b: 2} | rename -b {str upcase}
  ╭───┬───╮
  │ A │ 1 │
  │ B │ 2 │
  ╰───┴───╯

#  Rename fields based on fields' value
> {a: abc, b: def} | rename -b {|it| $it.value | str upcase}
  ╭─────┬─────╮
  │ ABC │ abc │
  │ DEF │ def │
  ╰─────┴─────╯
```
# User-Facing Changes


# 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
- `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-06-29 10:24:34 -05:00
..
charting revert: move to ahash (#9464) 2023-06-18 15:27:57 +12:00
conversions convert a string to a raw binary string of 0s and 1s (#9534) 2023-06-28 13:04:07 -05:00
database Improve type hovers (#9515) 2023-06-29 05:19:48 +12:00
date Update some help examples (#8759) 2023-04-05 18:36:00 -05:00
debug Apply nightly clippy fixes (#9381) 2023-06-08 18:49:58 +02:00
deprecated revert: move to ahash (#9464) 2023-06-18 15:27:57 +12:00
env revert: move to ahash (#9464) 2023-06-18 15:27:57 +12:00
experimental fix is-admin example (#9350) 2023-06-03 15:11:14 -05:00
filesystem Fix missing file names from rm errors (#9120) 2023-06-18 10:00:12 +02:00
filters rename: add -b flag to support closure input (#8948) 2023-06-29 10:24:34 -05:00
formats Apply nightly clippy fixes (#9482) 2023-06-20 10:17:33 +02:00
generators Document and critically review ShellError variants - Ep. 2 (#8326) 2023-03-06 11:31:07 +01:00
hash move common tools from nu-command to nu-cmd-base (#9455) 2023-06-22 14:45:54 -07:00
help Break up interdependencies of command crates (#9429) 2023-06-14 23:12:55 +02:00
math revert: move to ahash (#9464) 2023-06-18 15:27:57 +12:00
misc REFACTOR: move source out of deprecated commands (#9060) 2023-05-04 00:02:03 +02:00
network move common tools from nu-command to nu-cmd-base (#9455) 2023-06-22 14:45:54 -07:00
path revert: move to ahash (#9464) 2023-06-18 15:27:57 +12:00
platform add input_output type to input list to return string (#9557) 2023-06-29 08:27:25 -05:00
random Document and critically review ShellError variants - Ep. 3 (#8340) 2023-03-06 18:33:09 +01:00
shells Fix usage for the exit command. (#9450) 2023-06-16 10:09:02 +02:00
strings A new subcommand to str, str-expand. (#9290) 2023-06-28 12:57:44 -05:00
system revert: move to ahash (#9464) 2023-06-18 15:27:57 +12:00
viewers nu-table/ Fix indexing issue for table --expand (#9484) 2023-06-20 20:27:00 +12:00
default_context.rs A new subcommand to str, str-expand. (#9290) 2023-06-28 12:57:44 -05:00
example_test.rs revert: move to ahash (#9464) 2023-06-18 15:27:57 +12:00
hook.rs cratification: move the bytes command to nu-cmd-extra (#9509) 2023-06-23 12:23:08 -07:00
lib.rs cratification: move the bytes command to nu-cmd-extra (#9509) 2023-06-23 12:23:08 -07:00
progress_bar.rs cp progress bar implementation (#8012) 2023-02-22 11:57:38 -08:00
sort_utils.rs Support passing an empty list to sort, uniq, sort-by, and uniq-by (issue #5957) (#8669) 2023-03-29 19:55:38 -07:00