Skip to content

Commit 24c8e34

Browse files
authored
Bahex PR release notes (#1689)
1 parent 4029f7d commit 24c8e34

File tree

1 file changed

+161
-10
lines changed

1 file changed

+161
-10
lines changed

blog/2024-12-24-nushell_0_101_0.md

Lines changed: 161 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,117 @@ There may be (hopefully) minor breaking changes due to the startup configuration
7171

7272
With [#14295](https://github.com/nushell/nushell/pull/14295), dates can now be added to durations. Previously only durations could be added to dates.
7373

74+
### `group-by`
75+
76+
::: warning Breaking change
77+
See a full overview of the [breaking changes](#breaking-changes)
78+
:::
79+
80+
Thanks to [@Bahex](https://github.com/Bahex) in [#14337](https://github.com/nushell/nushell/pull/14337), the `group-by` command now supports grouping by multiple criteria (henceforth referred to as grouper).
81+
When using multiple groupers, the output is in the form of nested records.
82+
83+
```nu
84+
[
85+
[category color name];
86+
[fruit red apple]
87+
[fruit red strawberry]
88+
[vegetable red tomato]
89+
[fruit orange orange]
90+
[vegetable orange carrot]
91+
[vegetable orange pumpkin]
92+
] | group-by color category
93+
```
94+
```
95+
╭────────┬───────────────────────────────────────────────────────╮
96+
│ │ ╭───────────┬───────────────────────────────────────╮ │
97+
│ red │ │ │ ╭───┬──────────┬───────┬────────────╮ │ │
98+
│ │ │ fruit │ │ # │ category │ color │ name │ │ │
99+
│ │ │ │ ├───┼──────────┼───────┼────────────┤ │ │
100+
│ │ │ │ │ 0 │ fruit │ red │ apple │ │ │
101+
│ │ │ │ │ 1 │ fruit │ red │ strawberry │ │ │
102+
│ │ │ │ ╰───┴──────────┴───────┴────────────╯ │ │
103+
│ │ │ │ ╭───┬───────────┬───────┬────────╮ │ │
104+
│ │ │ vegetable │ │ # │ category │ color │ name │ │ │
105+
│ │ │ │ ├───┼───────────┼───────┼────────┤ │ │
106+
│ │ │ │ │ 0 │ vegetable │ red │ tomato │ │ │
107+
│ │ │ │ ╰───┴───────────┴───────┴────────╯ │ │
108+
│ │ ╰───────────┴───────────────────────────────────────╯ │
109+
│ │ ╭───────────┬──────────────────────────────────────╮ │
110+
│ orange │ │ │ ╭───┬──────────┬────────┬────────╮ │ │
111+
│ │ │ fruit │ │ # │ category │ color │ name │ │ │
112+
│ │ │ │ ├───┼──────────┼────────┼────────┤ │ │
113+
│ │ │ │ │ 0 │ fruit │ orange │ orange │ │ │
114+
│ │ │ │ ╰───┴──────────┴────────┴────────╯ │ │
115+
│ │ │ │ ╭───┬───────────┬────────┬─────────╮ │ │
116+
│ │ │ vegetable │ │ # │ category │ color │ name │ │ │
117+
│ │ │ │ ├───┼───────────┼────────┼─────────┤ │ │
118+
│ │ │ │ │ 0 │ vegetable │ orange │ carrot │ │ │
119+
│ │ │ │ │ 1 │ vegetable │ orange │ pumpkin │ │ │
120+
│ │ │ │ ╰───┴───────────┴────────┴─────────╯ │ │
121+
│ │ ╰───────────┴──────────────────────────────────────╯ │
122+
╰────────┴───────────────────────────────────────────────────────╯
123+
```
124+
125+
With the `--to-table` flag, instead of nested records, the output is in the form of a table with columns corresponding to each grouper and the `items` column.
126+
Each column corresponding to a `grouper` is named after it. For closure groupers, the columns are named with the scheme `closure_{i}`.
127+
128+
```nu
129+
.. | group-by color category --to-table
130+
```
131+
```
132+
╭───┬────────┬───────────┬───────────────────────────────────────╮
133+
│ # │ color │ category │ items │
134+
├───┼────────┼───────────┼───────────────────────────────────────┤
135+
│ 0 │ red │ fruit │ ╭───┬──────────┬───────┬────────────╮ │
136+
│ │ │ │ │ # │ category │ color │ name │ │
137+
│ │ │ │ ├───┼──────────┼───────┼────────────┤ │
138+
│ │ │ │ │ 0 │ fruit │ red │ apple │ │
139+
│ │ │ │ │ 1 │ fruit │ red │ strawberry │ │
140+
│ │ │ │ ╰───┴──────────┴───────┴────────────╯ │
141+
│ 1 │ red │ vegetable │ ╭───┬───────────┬───────┬────────╮ │
142+
│ │ │ │ │ # │ category │ color │ name │ │
143+
│ │ │ │ ├───┼───────────┼───────┼────────┤ │
144+
│ │ │ │ │ 0 │ vegetable │ red │ tomato │ │
145+
│ │ │ │ ╰───┴───────────┴───────┴────────╯ │
146+
│ 2 │ orange │ fruit │ ╭───┬──────────┬────────┬────────╮ │
147+
│ │ │ │ │ # │ category │ color │ name │ │
148+
│ │ │ │ ├───┼──────────┼────────┼────────┤ │
149+
│ │ │ │ │ 0 │ fruit │ orange │ orange │ │
150+
│ │ │ │ ╰───┴──────────┴────────┴────────╯ │
151+
│ 3 │ orange │ vegetable │ ╭───┬───────────┬────────┬─────────╮ │
152+
│ │ │ │ │ # │ category │ color │ name │ │
153+
│ │ │ │ ├───┼───────────┼────────┼─────────┤ │
154+
│ │ │ │ │ 0 │ vegetable │ orange │ carrot │ │
155+
│ │ │ │ │ 1 │ vegetable │ orange │ pumpkin │ │
156+
│ │ │ │ ╰───┴───────────┴────────┴─────────╯ │
157+
╰───┴────────┴───────────┴───────────────────────────────────────╯
158+
```
159+
160+
### `path self`
161+
162+
Thanks to [@Bahex](https://github.com/Bahex) in [#14303](https://github.com/nushell/nushell/pull/14303), this release adds the `path self` command.
163+
`path self` is a parse-time only command for getting the absolute path of the source file containing it, or any file relative to the source file.
164+
165+
```nushell
166+
const this_file = path self
167+
const this_directory = path self .
168+
```
169+
170+
### `term query`
171+
Thanks to [@Bahex](https://github.com/Bahex) in [#14427](https://github.com/nushell/nushell/pull/14427), this release adds the `term query` command.
172+
`term query` allows sending a query to your terminal emulator and reading the reply.
173+
174+
```nushell
175+
# Get cursor position
176+
term query (ansi cursor_position) --prefix (ansi csi) --terminator 'R'
177+
178+
# Get terminal background color.
179+
term query $'(ansi osc)10;?(ansi st)' --prefix $'(ansi osc)10;' --terminator (ansi st)
180+
181+
# Read clipboard content on terminals supporting OSC-52.
182+
term query $'(ansi osc)52;c;?(ansi st)' --prefix $'(ansi osc)52;c;' --terminator (ansi st)
183+
```
184+
74185
## Breaking changes
75186

76187
### `++` operator
@@ -124,6 +235,47 @@ To make the deferred evaluation more explicit, the `timeit` command can now only
124235

125236
The `cpu_usage` column outputted by `sys cpu` works by sampling the CPU over a 400ms period. This wait long time is unhelpful if you are only interested in other information about the CPU like the number of cores (i.e., `sys cpu | length`). With [#14485](https://github.com/nushell/nushell/pull/14485), the `cpu_usage` column is now gated behind the `--long` flag. This way, `sys cpu` will take around 0-2ms instead of 400ms by default.
126237

238+
### `from csv` and `from tsv`
239+
Thanks to [@Bahex](https://github.com/Bahex) in [#14399](https://github.com/nushell/nushell/pull/14399), parsing csv and tsv content with the `--flexible` flag is more flexible than before.
240+
Previously, the first row of csv or tsv content would determine the number of columns, and rows containing more values than the determined columns would be truncated, losing those extra values.
241+
242+
With this release, that is no longer the case.
243+
Now, `--flexible` flag means the number of columns aren't limited by the first row and can have not just less but also more values than the first row.
244+
245+
```csv
246+
value
247+
1,aaa
248+
2,bbb
249+
3
250+
4,ddd
251+
5,eee,extra
252+
```
253+
```nu
254+
.. | from csv --flexible --noheaders
255+
```
256+
```
257+
╭─#─┬─column0─┬─column1─┬─column2─╮
258+
│ 0 │ value │ ❎ │ ❎ │
259+
│ 1 │ 1 │ aaa │ ❎ │
260+
│ 2 │ 2 │ bbb │ ❎ │
261+
│ 3 │ 3 │ ❎ │ ❎ │
262+
│ 4 │ 4 │ ddd │ ❎ │
263+
│ 5 │ 5 │ eee │ extra │
264+
╰─#─┴─column0─┴─column1─┴─column2─╯
265+
```
266+
267+
### `std/iter scan`
268+
269+
Thanks to [@Bahex](https://github.com/Bahex) in [#14596](https://github.com/nushell/nushell/pull/14596), the order of `scan`'s closure's parameters are flipped to be consistent with `reduce`.
270+
The closure now also receives the accumulator value as pipeline input as well.
271+
272+
```nushell
273+
> [a b c d] | iter scan "" {|x, y| [$x, $y] | str join} -n
274+
# To keep its behavior same, this command should be changed to either of the following
275+
> [a b c d] | iter scan "" {|it, acc| [$acc, $it] | str join} -n
276+
> [a b c d] | iter scan "" {|it| append $it | str join} -n
277+
```
278+
127279
## Deprecations
128280

129281
### `split-by`
@@ -172,20 +324,19 @@ Thanks to all the contributors below for helping us solve issues, improve docume
172324
|[@132ikl](https://github.com/132ikl)|Change tests which may invoke externals to use non-conflicting names|[#14516](https://github.com/nushell/nushell/pull/14516)|
173325

174326
<!-- |[@132ikl](https://github.com/132ikl)|Remove grid icons deprecation warning|[#14526](https://github.com/nushell/nushell/pull/14526)| -->
175-
<!-- |[@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)| -->
176-
<!-- |[@Bahex](https://github.com/Bahex)|add multiple grouper support to `group-by`|[#14337](https://github.com/nushell/nushell/pull/14337)| -->
177327

328+
|[@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)|
329+
|[@Bahex](https://github.com/Bahex)|add multiple grouper support to `group-by`|[#14337](https://github.com/nushell/nushell/pull/14337)|
178330
|[@Bahex](https://github.com/Bahex)|fix(group-by): re #14337 name collision prevention|[#14360](https://github.com/nushell/nushell/pull/14360)|
179-
180-
<!-- |[@Bahex](https://github.com/Bahex)|truly flexible csv/tsv parsing|[#14399](https://github.com/nushell/nushell/pull/14399)| -->
181-
<!-- |[@Bahex](https://github.com/Bahex)|Add `term query`, for querying information from terminals.|[#14427](https://github.com/nushell/nushell/pull/14427)| -->
182-
<!-- |[@Bahex](https://github.com/Bahex)|`term query`: refactor, add `--prefix` flag|[#14446](https://github.com/nushell/nushell/pull/14446)| -->
183-
<!-- |[@Bahex](https://github.com/Bahex)|Propagate existing errors in insert and merge|[#14453](https://github.com/nushell/nushell/pull/14453)| -->
184-
<!-- |[@Bahex](https://github.com/Bahex)|lsp and --ide-check fix for `path self` related diagnostics|[#14538](https://github.com/nushell/nushell/pull/14538)| -->
185-
331+
|[@Bahex](https://github.com/Bahex)|truly flexible csv/tsv parsing|[#14399](https://github.com/nushell/nushell/pull/14399)|
332+
|[@Bahex](https://github.com/Bahex)|Add `term query`, for querying information from terminals.|[#14427](https://github.com/nushell/nushell/pull/14427)|
333+
|[@Bahex](https://github.com/Bahex)|`term query`: refactor, add `--prefix` flag|[#14446](https://github.com/nushell/nushell/pull/14446)|
334+
|[@Bahex](https://github.com/Bahex)|Propagate existing errors in insert and merge|[#14453](https://github.com/nushell/nushell/pull/14453)|
335+
|[@Bahex](https://github.com/Bahex)|lsp and --ide-check fix for `path self` related diagnostics|[#14538](https://github.com/nushell/nushell/pull/14538)|
186336
|[@Bahex](https://github.com/Bahex)|docs(reduce): add example demonstrating accumulator as pipeline input|[#14593](https://github.com/nushell/nushell/pull/14593)|
337+
|[@Bahex](https://github.com/Bahex)|remove the deprecated index argument from filter commands' closure signature|[#14594](https://github.com/nushell/nushell/pull/14594)|
338+
|[@Bahex](https://github.com/Bahex)|`std/iter scan`: change closure signature to be consistent with `reduce`|[#14596](https://github.com/nushell/nushell/pull/14596)|
187339

188-
<!-- |[@Bahex](https://github.com/Bahex)|remove the deprecated index argument from filter commands' closure signature|[#14594](https://github.com/nushell/nushell/pull/14594)| -->
189340
<!-- |[@Beinsezii](https://github.com/Beinsezii)|command/http/client use CRLF for headers join instead of LF|[#14417](https://github.com/nushell/nushell/pull/14417)| -->
190341

191342
|[@DziubaMaksym](https://github.com/DziubaMaksym)|fix: sample_config|[#14465](https://github.com/nushell/nushell/pull/14465)|

0 commit comments

Comments
 (0)