Skip to content

Commit 939a8f8

Browse files
committed
Rose's changes
1 parent 8451106 commit 939a8f8

File tree

1 file changed

+63
-10
lines changed

1 file changed

+63
-10
lines changed

blog/2024-12-24-nushell_0_101_0.md

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,52 @@ term query $'(ansi osc)10;?(ansi st)' --prefix $'(ansi osc)10;' --terminator (an
106106
term query $'(ansi osc)52;c;?(ansi st)' --prefix $'(ansi osc)52;c;' --terminator (ansi st)
107107
```
108108

109+
### `merge deep`
110+
111+
To merge nested record structures we now have `merge deep` as a subcommand of `merge` which only operates on the flat structure of tables.
112+
113+
Here you can see how it is used to update a record with fields from a given record, by either adding the fields or replacing those leaf nodes that share a common cellpath.
114+
```nushell
115+
{a: {foo: 123 bar: "overwrite me"}, b: [1, 2, 3]} | merge deep {a: {bar: 456, baz: 789}, b: [4, 5, 6]}
116+
# => ╭───┬───────────────╮
117+
# => │ │ ╭─────┬─────╮ │
118+
# => │ a │ │ foo │ 123 │ │
119+
# => │ │ │ bar │ 456 │ │
120+
# => │ │ │ baz │ 789 │ │
121+
# => │ │ ╰─────┴─────╯ │
122+
# => │ │ ╭───┬───╮ │
123+
# => │ b │ │ 0 │ 4 │ │
124+
# => │ │ │ 1 │ 5 │ │
125+
# => │ │ │ 2 │ 6 │ │
126+
# => │ │ ╰───┴───╯ │
127+
# => ╰───┴───────────────╯
128+
```
129+
130+
While the record entries get updated based on the path, by default lists at a given path are updated by replacement.
131+
132+
`merge deep` also has different strategies for merging inner lists and tables. For example, you can use the `append` strategy to _merge_ the inner `b` list instead of overwriting it.
133+
134+
```nushell
135+
{a: {foo: 123 bar: "overwrite me"}, b: [1, 2, 3]} | merge deep --strategy=append {a: {bar: 456, baz: 789}, b: [4, 5, 6]}
136+
# => ╭───┬───────────────╮
137+
# => │ │ ╭─────┬─────╮ │
138+
# => │ a │ │ foo │ 123 │ │
139+
# => │ │ │ bar │ 456 │ │
140+
# => │ │ │ baz │ 789 │ │
141+
# => │ │ ╰─────┴─────╯ │
142+
# => │ │ ╭───┬───╮ │
143+
# => │ b │ │ 0 │ 1 │ │
144+
# => │ │ │ 1 │ 2 │ │
145+
# => │ │ │ 2 │ 3 │ │
146+
# => │ │ │ 3 │ 4 │ │
147+
# => │ │ │ 4 │ 5 │ │
148+
# => │ │ │ 5 │ 6 │ │
149+
# => │ │ ╰───┴───╯ │
150+
# => ╰───┴───────────────╯
151+
```
152+
153+
This command is the work of a productive collaboration by [@132ikl](https://github.com/132ikl) and [@Bahex](https://github.com/Bahex).
154+
109155
### `utouch`
110156

111157
This release adds the new `utouch` command, utilizing uutils/coreutils! In addition to all the flags of `touch`, `utouch` also has a `--timestamp` and `--date` flag to specify the timestamp to use. Eventually, the `utouch` command will replace the `touch` command.
@@ -372,6 +418,11 @@ In [#14424](https://github.com/nushell/nushell/pull/14424), some changes were ma
372418

373419
Thanks to [@sgvictorino](https://github.com/sgvictorino) in [#14353](https://github.com/nushell/nushell/pull/14353), modules with special characters in their name will be normalized by converting these special characters to underscores (`_`). Previously, it was not possible to use these modules after importing them.
374420

421+
### `table` formatting and the `display_output` hook
422+
With [#14361](https://github.com/nushell/nushell/pull/14361) by [@132ikl](https://github.com/132ikl) our machinery to format structured now follows a simpler logic.
423+
If a `$env.config.hooks.display_output` hook is set, it is fully responsible for formatting the structured data, e.g. by invoking `table` with custom settings. Only if it is not set by `null` will `table` without arguments be run by default.
424+
Previously the output logic would invoke `table` regardless on top of the formatting by your `display_output` hook. This avoids some spurious formatting attempts.
425+
375426
## Deprecations
376427

377428
### `split-by`
@@ -421,6 +472,10 @@ The `http` commands now use CRLF when joining headers to match the HTTP specific
421472

422473
`scope variables` now lists constant variables in scope (when using the IR evaluator) thanks to [@sgvictorino](https://github.com/sgvictorino in [#14577](https://github.com/nushell/nushell/pull/14577).
423474

475+
### `help` system
476+
477+
[@132ikl](https://github.com/132ikl) fixed a long standing issue in the help system, where commands with the same name but different module paths clashed. Now the `help <name>` correctly refers to the name of a command like it is visible in the scope through the definitions or `use` imports thanks to [#14490](https://github.com/nushell/nushell/pull/14490).
478+
424479
# Notes for plugin developers
425480

426481
# Hall of fame
@@ -430,6 +485,7 @@ Thanks to all the contributors below for helping us solve issues, improve docume
430485
| author | title | link |
431486
| -------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ------------------------------------------------------- |
432487
| [@132ikl](https://github.com/132ikl) | Change tests which may invoke externals to use non-conflicting names | [#14516](https://github.com/nushell/nushell/pull/14516) |
488+
| [@132ikl](https://github.com/132ikl) | Make `glob` stream | [#14495](https://github.com/nushell/nushell/pull/14495) |
433489
| [@Bahex](https://github.com/Bahex) | docs(reduce): add example demonstrating accumulator as pipeline input | [#14593](https://github.com/nushell/nushell/pull/14593) |
434490
| [@Bahex](https://github.com/Bahex) | test(path self): Add tests | [#14607](https://github.com/nushell/nushell/pull/14607) |
435491
| [@DziubaMaksym](https://github.com/DziubaMaksym) | fix: sample_config | [#14465](https://github.com/nushell/nushell/pull/14465) |
@@ -450,17 +506,14 @@ Thanks to all the contributors below for helping us solve issues, improve docume
450506
| author | title | link |
451507
| ------ | ----- | ---- |
452508

453-
<!-- |[@132ikl](https://github.com/132ikl)|Rely on `display_output` hook for formatting values from evaluations|[#14361](https://github.com/nushell/nushell/pull/14361)| -->
454-
<!-- |[@132ikl](https://github.com/132ikl)|Make length only operate on supported input types|[#14475](https://github.com/nushell/nushell/pull/14475)| -->
455-
<!-- |[@132ikl](https://github.com/132ikl)|Add label rendering to try/catch rendered errors|[#14477](https://github.com/nushell/nushell/pull/14477)| -->
456-
<!-- |[@132ikl](https://github.com/132ikl)|Change `help commands` to use name from scope instead of the name from the declaration|[#14490](https://github.com/nushell/nushell/pull/14490)| -->
457-
<!-- |[@132ikl](https://github.com/132ikl)|Make `glob` stream|[#14495](https://github.com/nushell/nushell/pull/14495)| -->
458-
509+
|[@132ikl](https://github.com/132ikl)|Rely on `display_output` hook for formatting values from evaluations|[#14361](https://github.com/nushell/nushell/pull/14361)|
510+
|[@132ikl](https://github.com/132ikl)|Make length only operate on supported input types|[#14475](https://github.com/nushell/nushell/pull/14475)|
511+
|[@132ikl](https://github.com/132ikl)|Add label rendering to try/catch rendered errors|[#14477](https://github.com/nushell/nushell/pull/14477)|
512+
|[@132ikl](https://github.com/132ikl)|Change `help commands` to use name from scope instead of the name from the declaration|[#14490](https://github.com/nushell/nushell/pull/14490)|
513+
|[@132ikl](https://github.com/132ikl)|Make `glob` stream|[#14495](https://github.com/nushell/nushell/pull/14495)|
459514
|[@132ikl](https://github.com/132ikl)|Change tests which may invoke externals to use non-conflicting names|[#14516](https://github.com/nushell/nushell/pull/14516)|
460-
461-
<!-- |[@132ikl](https://github.com/132ikl)|Add `merge deep` command|[#14525](https://github.com/nushell/nushell/pull/14525)| -->
462-
<!-- |[@132ikl](https://github.com/132ikl)|Remove grid icons deprecation warning|[#14526](https://github.com/nushell/nushell/pull/14526)| -->
463-
515+
|[@132ikl](https://github.com/132ikl)|Add `merge deep` command|[#14525](https://github.com/nushell/nushell/pull/14525)|
516+
|[@132ikl](https://github.com/132ikl)|Remove grid icons deprecation warning|[#14526](https://github.com/nushell/nushell/pull/14526)|
464517
|[@Bahex](https://github.com/Bahex)|Add `path self` command for getting absolute paths to files at parse time|[#14303](https://github.com/nushell/nushell/pull/14303)|
465518
|[@Bahex](https://github.com/Bahex)|add multiple grouper support to `group-by`|[#14337](https://github.com/nushell/nushell/pull/14337)|
466519
|[@Bahex](https://github.com/Bahex)|fix(group-by): re #14337 name collision prevention|[#14360](https://github.com/nushell/nushell/pull/14360)|

0 commit comments

Comments
 (0)