Skip to content

Commit 29adfc3

Browse files
committed
Refresh Nu command docs for v0.101
1 parent 0df484a commit 29adfc3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+861
-124
lines changed

.vuepress/configs/sidebar/command_categories.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const commandCategories = [
1010
'/commands/categories/date.md',
1111
'/commands/categories/debug.md',
1212
'/commands/categories/default.md',
13+
'/commands/categories/deprecated.md',
1314
'/commands/categories/env.md',
1415
'/commands/categories/expression.md',
1516
'/commands/categories/filesystem.md',

commands/categories/deprecated.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<th>Description</th>
2121
</tr>
2222
<tr v-for="command in commands">
23-
<td><a :href="command.path">{{ command.title }}</a></td>
23+
<td><a :href="$withBase(command.path)">{{ command.title }}</a></td>
2424
<td style="white-space: pre-wrap;">{{ command.frontmatter.usage }}</td>
2525
</tr>
2626
</table>

commands/docs/ast.md

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ usage: |
2020

2121
## Flags
2222

23-
- `--json, -j`: serialize to json
24-
- `--minify, -m`: minify the nuon or json output
23+
- `--json, -j`: Serialize to json
24+
- `--minify, -m`: Minify the nuon or json output
25+
- `--flatten, -f`: An easier to read version of the ast
2526

2627
## Parameters
2728

@@ -30,9 +31,9 @@ usage: |
3031

3132
## Input/output types:
3233

33-
| input | output |
34-
| ------ | ------ |
35-
| string | record |
34+
| input | output |
35+
| ------- | ------ |
36+
| nothing | table |
3637

3738
## Examples
3839

@@ -65,3 +66,57 @@ Print the ast of a pipeline with an error, as json, minified
6566
> ast 'for x in 1..10 { echo $x ' --json --minify
6667
6768
```
69+
70+
Print the ast of a string flattened
71+
```nu
72+
> ast "'hello'" --flatten
73+
╭───┬─────────┬──────────────┬───────────────╮
74+
│ # │ content │ shape │ span │
75+
├───┼─────────┼──────────────┼───────────────┤
76+
│ 0 │ 'hello' │ shape_string │ ╭───────┬───╮ │
77+
│ │ │ │ │ start │ 0 │ │
78+
│ │ │ │ │ end │ 7 │ │
79+
│ │ │ │ ╰───────┴───╯ │
80+
╰───┴─────────┴──────────────┴───────────────╯
81+
82+
```
83+
84+
Print the ast of a string flattened, as json, minified
85+
```nu
86+
> ast "'hello'" --flatten --json --minify
87+
[{"content":"'hello'","shape":"shape_string","span":{"start":0,"end":7}}]
88+
```
89+
90+
Print the ast of a pipeline flattened
91+
```nu
92+
> ast 'ls | sort-by type name -i' --flatten
93+
╭───┬─────────┬────────────────────┬────────────────╮
94+
│ # │ content │ shape │ span │
95+
├───┼─────────┼────────────────────┼────────────────┤
96+
│ 0 │ ls │ shape_external │ ╭───────┬───╮ │
97+
│ │ │ │ │ start │ 0 │ │
98+
│ │ │ │ │ end │ 2 │ │
99+
│ │ │ │ ╰───────┴───╯ │
100+
│ 1 │ | │ shape_pipe │ ╭───────┬───╮ │
101+
│ │ │ │ │ start │ 3 │ │
102+
│ │ │ │ │ end │ 4 │ │
103+
│ │ │ │ ╰───────┴───╯ │
104+
│ 2 │ sort-by │ shape_internalcall │ ╭───────┬────╮ │
105+
│ │ │ │ │ start │ 5 │ │
106+
│ │ │ │ │ end │ 12 │ │
107+
│ │ │ │ ╰───────┴────╯ │
108+
│ 3 │ type │ shape_string │ ╭───────┬────╮ │
109+
│ │ │ │ │ start │ 13 │ │
110+
│ │ │ │ │ end │ 17 │ │
111+
│ │ │ │ ╰───────┴────╯ │
112+
│ 4 │ name │ shape_string │ ╭───────┬────╮ │
113+
│ │ │ │ │ start │ 18 │ │
114+
│ │ │ │ │ end │ 22 │ │
115+
│ │ │ │ ╰───────┴────╯ │
116+
│ 5 │ -i │ shape_flag │ ╭───────┬────╮ │
117+
│ │ │ │ │ start │ 23 │ │
118+
│ │ │ │ │ end │ 25 │ │
119+
│ │ │ │ ╰───────┴────╯ │
120+
╰───┴─────────┴────────────────────┴────────────────╯
121+
122+
```

commands/docs/chunk-by.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
title: chunk-by
3+
categories: |
4+
filters
5+
version: 0.100.0
6+
filters: |
7+
Divides a sequence into sub-sequences based on a closure.
8+
usage: |
9+
Divides a sequence into sub-sequences based on a closure.
10+
---
11+
<!-- This file is automatically generated. Please edit the command in https://github.com/nushell/nushell instead. -->
12+
13+
# `chunk-by` for [filters](/commands/categories/filters.md)
14+
15+
<div class='command-title'>Divides a sequence into sub-sequences based on a closure.</div>
16+
17+
## Signature
18+
19+
```> chunk-by {flags} (closure)```
20+
21+
## Parameters
22+
23+
- `closure`: The closure to run.
24+
25+
26+
## Input/output types:
27+
28+
| input | output |
29+
| --------- | --------------- |
30+
| list\<any\> | list\<list\<any\>\> |
31+
| range | list\<list\<any\>\> |
32+
## Examples
33+
34+
Chunk data into runs of larger than zero or not.
35+
```nu
36+
> [1, 3, -2, -2, 0, 1, 2] | chunk-by {|it| $it >= 0 }
37+
╭───┬────────────╮
38+
│ 0 │ ╭───┬───╮ │
39+
│ │ │ 0 │ 1 │ │
40+
│ │ │ 1 │ 3 │ │
41+
│ │ ╰───┴───╯ │
42+
│ 1 │ ╭───┬────╮ │
43+
│ │ │ 0 │ -2 │ │
44+
│ │ │ 1 │ -2 │ │
45+
│ │ ╰───┴────╯ │
46+
│ 2 │ ╭───┬───╮ │
47+
│ │ │ 0 │ 0 │ │
48+
│ │ │ 1 │ 1 │ │
49+
│ │ │ 2 │ 2 │ │
50+
│ │ ╰───┴───╯ │
51+
╰───┴────────────╯
52+
53+
```
54+
55+
Identify repetitions in a string
56+
```nu
57+
> [a b b c c c] | chunk-by { |it| $it }
58+
╭───┬───────────╮
59+
│ 0 │ ╭───┬───╮ │
60+
│ │ │ 0 │ a │ │
61+
│ │ ╰───┴───╯ │
62+
│ 1 │ ╭───┬───╮ │
63+
│ │ │ 0 │ b │ │
64+
│ │ │ 1 │ b │ │
65+
│ │ ╰───┴───╯ │
66+
│ 2 │ ╭───┬───╮ │
67+
│ │ │ 0 │ c │ │
68+
│ │ │ 1 │ c │ │
69+
│ │ │ 2 │ c │ │
70+
│ │ ╰───┴───╯ │
71+
╰───┴───────────╯
72+
73+
```
74+
75+
Chunk values of range by predicate
76+
```nu
77+
> (0..8) | chunk-by { |it| $it // 3 }
78+
╭───┬───────────╮
79+
│ 0 │ ╭───┬───╮ │
80+
│ │ │ 0 │ 0 │ │
81+
│ │ │ 1 │ 1 │ │
82+
│ │ │ 2 │ 2 │ │
83+
│ │ ╰───┴───╯ │
84+
│ 1 │ ╭───┬───╮ │
85+
│ │ │ 0 │ 3 │ │
86+
│ │ │ 1 │ 4 │ │
87+
│ │ │ 2 │ 5 │ │
88+
│ │ ╰───┴───╯ │
89+
│ 2 │ ╭───┬───╮ │
90+
│ │ │ 0 │ 6 │ │
91+
│ │ │ 1 │ 7 │ │
92+
│ │ │ 2 │ 8 │ │
93+
│ │ ╰───┴───╯ │
94+
╰───┴───────────╯
95+
96+
```
97+
98+
## Notes
99+
chunk-by applies the given closure to each value of the input list, and groups
100+
consecutive elements that share the same closure result value into lists.

commands/docs/config.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ You must use one of the following subcommands. Using this command as-is will onl
3030

3131
## Subcommands:
3232

33-
| name | description | type |
34-
| ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------- | -------- |
35-
| [`config env`](/commands/docs/config_env.md) | Edit nu environment configurations. | built-in |
36-
| [`config nu`](/commands/docs/config_nu.md) | Edit nu configurations. | built-in |
37-
| [`config reset`](/commands/docs/config_reset.md) | Reset nushell environment configurations to default, and saves old config files in the config location as oldconfig.nu and oldenv.nu. | built-in |
33+
| name | description | type |
34+
| ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | -------- |
35+
| [`config env`](/commands/docs/config_env.md) | Edit nu environment configurations. | built-in |
36+
| [`config flatten`](/commands/docs/config_flatten.md) | Show the current configuration in a flattened form. | built-in |
37+
| [`config nu`](/commands/docs/config_nu.md) | Edit nu configurations. | built-in |
38+
| [`config reset`](/commands/docs/config_reset.md) | Reset nushell environment configurations to default, and saves old config files in the config location as oldconfig.nu and oldenv.nu. | built-in |

commands/docs/config_env.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ usage: |
2020

2121
## Flags
2222

23-
- `--default, -d`: Print default `env.nu` file instead.
23+
- `--default, -d`: Print the internal default `env.nu` file instead.
24+
- `--doc, -s`: Print a commented `env.nu` with documentation instead.
2425

2526

2627
## Input/output types:
@@ -31,20 +32,20 @@ usage: |
3132

3233
## Examples
3334

34-
allow user to open and update nu env
35+
open user's env.nu in the default editor
3536
```nu
3637
> config env
3738
3839
```
3940

40-
allow user to print default `env.nu` file
41+
pretty-print a commented `env.nu` that explains common settings
4142
```nu
42-
> config env --default,
43+
> config env --doc | nu-highlight,
4344
4445
```
4546

46-
allow saving the default `env.nu` locally
47+
pretty-print the internal `env.nu` file which is loaded before the user's environment
4748
```nu
48-
> config env --default | save -f ~/.config/nushell/default_env.nu
49+
> config env --default | nu-highlight,
4950
5051
```

commands/docs/config_flatten.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: config flatten
3+
categories: |
4+
debug
5+
version: 0.100.0
6+
debug: |
7+
Show the current configuration in a flattened form.
8+
usage: |
9+
Show the current configuration in a flattened form.
10+
---
11+
<!-- This file is automatically generated. Please edit the command in https://github.com/nushell/nushell instead. -->
12+
13+
# `config flatten` for [debug](/commands/categories/debug.md)
14+
15+
<div class='command-title'>Show the current configuration in a flattened form.</div>
16+
17+
## Signature
18+
19+
```> config flatten {flags} ```
20+
21+
22+
## Input/output types:
23+
24+
| input | output |
25+
| ------- | ------ |
26+
| nothing | record |
27+
28+
## Examples
29+
30+
Show the current configuration in a flattened form
31+
```nu
32+
> config flatten
33+
34+
```

commands/docs/config_nu.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ usage: |
2020

2121
## Flags
2222

23-
- `--default, -d`: Print default `config.nu` file instead.
23+
- `--default, -d`: Print the internal default `config.nu` file instead.
24+
- `--doc, -s`: Print a commented `config.nu` with documentation instead.
2425

2526

2627
## Input/output types:
@@ -31,20 +32,20 @@ usage: |
3132

3233
## Examples
3334

34-
allow user to open and update nu config
35+
open user's config.nu in the default editor
3536
```nu
3637
> config nu
3738
3839
```
3940

40-
allow user to print default `config.nu` file
41+
pretty-print a commented `config.nu` that explains common settings
4142
```nu
42-
> config nu --default,
43+
> config nu --doc | nu-highlight
4344
4445
```
4546

46-
allow saving the default `config.nu` locally
47+
pretty-print the internal `config.nu` file which is loaded before user's config
4748
```nu
48-
> config nu --default | save -f ~/.config/nushell/default_config.nu
49+
> config nu --default | nu-highlight
4950
5051
```

commands/docs/date_to-record.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
---
22
title: date to-record
33
categories: |
4-
date
4+
deprecated
55
version: 0.100.0
6-
date: |
6+
deprecated: |
77
Convert the date into a record.
88
usage: |
99
Convert the date into a record.
1010
---
1111
<!-- This file is automatically generated. Please edit the command in https://github.com/nushell/nushell instead. -->
1212

13-
# `date to-record` for [date](/commands/categories/date.md)
13+
# `date to-record` for [deprecated](/commands/categories/deprecated.md)
1414

1515
<div class='command-title'>Convert the date into a record.</div>
1616

commands/docs/date_to-table.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
---
22
title: date to-table
33
categories: |
4-
date
4+
deprecated
55
version: 0.100.0
6-
date: |
6+
deprecated: |
77
Convert the date into a structured table.
88
usage: |
99
Convert the date into a structured table.
1010
---
1111
<!-- This file is automatically generated. Please edit the command in https://github.com/nushell/nushell instead. -->
1212

13-
# `date to-table` for [date](/commands/categories/date.md)
13+
# `date to-table` for [deprecated](/commands/categories/deprecated.md)
1414

1515
<div class='command-title'>Convert the date into a structured table.</div>
1616

0 commit comments

Comments
 (0)