Files
nushell/tests/parsing/samples/recursive_func_with_alias.nu
Bahex beb3ec6a49 refactor(get,select,reject)!: deprecate --ignore-errors in favor of --optional (#16007)
# Description
As decided on the team meeting on 2025-06-19, rename `--ignore-errors
(-i)` to `--optional (-o)` with a (currently) indefinite grace period.

After `--ignore-errors (-i)` is removed, the short flag `-i` can be used
for `--ignore-case` (not implemented as of this PR)

# User-Facing Changes
`get`/`select`/`reject`: rename `--ignore-errors (-i)` to `--optional
(-o)` to better reflect its behavior.

# Tests + Formatting
- 🟢 toolkit fmt
- 🟢 toolkit clippy
- 🟢 toolkit test
- 🟢 toolkit test stdlib

# After Submitting
Update docs and inform third parties that integrate with nushell.

---------

Co-authored-by: Bahex <17417311+Bahex@users.noreply.github.com>
2025-07-15 00:26:41 -04:00

23 lines
775 B
Plaintext

alias "orig update" = update
# Update a column to have a new value if it exists.
#
# If the column exists with the value `null` it will be skipped.
export def "update" [
field: cell-path # The name of the column to maybe update.
value: any # The new value to give the cell(s), or a closure to create the value.
]: [record -> record, table -> table, list<any> -> list<any>] {
let input = $in
match ($input | describe | str replace --regex '<.*' '') {
record => {
if ($input | get -o $field) != null {
$input | orig update $field $value
} else { $input }
}
table|list => {
$input | each {|| update $field $value }
}
_ => { $input | orig update $field $value }
}
}