Skip to content

Commit 0b47025

Browse files
authored
Consistently use nu as code block lang (#1807)
CONTRIBUTING.md defines a preference of `nu` over `nushell`, which overwhelmingly matches our code blocks. These 66 occurrences were the outliers.
1 parent c8e3572 commit 0b47025

File tree

9 files changed

+66
-66
lines changed

9 files changed

+66
-66
lines changed

book/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ The Standard Library also includes a helper command. The default `path add` beha
136136
a directory so that it has higher precedence than the rest of the path. For example, the following can be
137137
added to your startup config:
138138

139-
```nushell
139+
```nu
140140
use std/util "path add"
141141
path add "~/.local/bin"
142142
path add ($env.CARGO_HOME | path join "bin")

book/operators.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ Suppose you have multiple lists you want to concatenate together, but you also w
142142
some individual values. This can be done with `append` and `prepend`, but the spread
143143
operator can let you do it more easily.
144144

145-
```nushell
145+
```nu
146146
let dogs = [Spot, Teddy, Tommy]
147147
let cats = ["Mr. Humphrey Montgomery", Kitten]
148148
[
@@ -166,7 +166,7 @@ let cats = ["Mr. Humphrey Montgomery", Kitten]
166166
```
167167

168168
The below code is an equivalent version using `append`:
169-
```nushell
169+
```nu
170170
$dogs |
171171
append Polly |
172172
append ($cats | each { |elt| $"($elt) \(cat\)" }) |
@@ -186,7 +186,7 @@ only be used before variables (`...$foo`), subexpressions (`...(foo)`), and list
186186
The `...` also won't be recognized as the spread operator if there's any whitespace between it and
187187
the next expression:
188188

189-
```nushell
189+
```nu
190190
[ ... [] ]
191191
# => ╭───┬────────────────╮
192192
# => │ 0 │ ... │
@@ -201,14 +201,14 @@ This is mainly so that `...` won't be confused for the spread operator in comman
201201
Let's say you have a record with some configuration information and you want to add more fields to
202202
this record:
203203

204-
```nushell
204+
```nu
205205
let config = { path: /tmp, limit: 5 }
206206
```
207207

208208
You can make a new record with all the fields of `$config` and some new additions using the spread
209209
operator. You can use the spread multiple records inside a single record literal.
210210

211-
```nushell
211+
```nu
212212
{
213213
...$config,
214214
users: [alice bob],
@@ -244,7 +244,7 @@ external command.
244244

245245
Here is an example custom command that has a rest parameter:
246246

247-
```nushell
247+
```nu
248248
def foo [ --flag req opt? ...args ] { [$flag, $req, $opt, $args] | to nuon }
249249
```
250250

@@ -255,7 +255,7 @@ If you have a list of arguments to pass to `args`, you can spread it the same wa
255255
[inside a list literal](#in-list-literals). The same rules apply: the spread operator is only
256256
recognized before variables, subexpressions, and list literals, and no whitespace is allowed in between.
257257

258-
```nushell
258+
```nu
259259
foo "bar" "baz" ...[1 2 3] # With ..., the numbers are treated as separate arguments
260260
# => [false, bar, baz, [1, 2, 3]]
261261
foo "bar" "baz" [1 2 3] # Without ..., [1 2 3] is treated as a single argument
@@ -265,30 +265,30 @@ foo "bar" "baz" [1 2 3] # Without ..., [1 2 3] is treated as a single argument
265265
A more useful way to use the spread operator is if you have another command with a rest parameter
266266
and you want it to forward its arguments to `foo`:
267267

268-
```nushell
268+
```nu
269269
def bar [ ...args ] { foo --flag "bar" "baz" ...$args }
270270
bar 1 2 3
271271
# => [true, bar, baz, [1, 2, 3]]
272272
```
273273

274274
You can spread multiple lists in a single call, and also intersperse individual arguments:
275275

276-
```nushell
276+
```nu
277277
foo "bar" "baz" 1 ...[2 3] 4 5 ...(6..9 | take 2) last
278278
# => [false, bar, baz, [1, 2, 3, 4, 5, 6, 7, last]]
279279
```
280280

281281
Flags/named arguments can go after a spread argument, just like they can go after regular rest arguments:
282282

283-
```nushell
283+
```nu
284284
foo "bar" "baz" 1 ...[2 3] --flag 4
285285
# => [true, bar, baz, [1, 2, 3, 4]]
286286
```
287287

288288
If a spread argument comes before an optional positional parameter, that optional parameter is treated
289289
as being omitted:
290290

291-
```nushell
291+
```nu
292292
foo "bar" ...[1 2] "not opt" # The null means no argument was given for opt
293293
# => [false, bar, null, [1, 2, "not opt"]]
294294
```

book/pipelines.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ Compare the following two command-lines that create a directory with tomorrow's
6464

6565
Using subexpressions:
6666

67-
```nushell
67+
```nu
6868
mkdir $'((date now) + 1day | format date '%F') Report'
6969
```
7070

7171
or using pipelines:
7272

73-
```nushell
73+
```nu
7474
date now # 1: today
7575
| $in + 1day # 2: tomorrow
7676
| format date '%F' # 3: Format as YYYY-MM-DD
@@ -95,21 +95,21 @@ Let's examine the contents of `$in` on each line of the above example:
9595

9696
Certain [filter commands](/commands/categories/filters.html) may modify the pipeline input to their closure in order to provide more convenient access to the expected context. For example:
9797

98-
```nushell
98+
```nu
9999
1..10 | each {$in * 2}
100100
```
101101

102102
Rather than referring to the entire range of 10 digits, the `each` filter modifies `$in` to refer to the value of the _current iteration_.
103103

104104
In most filters, the pipeline input and its resulting `$in` will be the same as the closure parameter. For the `each` filter, the following example is equivalent to the one above:
105105

106-
```nushell
106+
```nu
107107
1..10 | each {|value| $value * 2}
108108
```
109109

110110
However, some filters will assign an even more convenient value to their closures' input. The `update` filter is one example. The pipeline input to the `update` command's closure (as well as `$in`) refers to the _column_ being updated, while the closure parameter refers to the entire record. As a result, the following two examples are also equivalent:
111111

112-
```nushell
112+
```nu
113113
ls | update name {|file| $file.name | str upcase}
114114
ls | update name {str upcase}
115115
```
@@ -257,7 +257,7 @@ While `$in` can be reused as demonstrated above, assigning its value to another
257257

258258
Example:
259259

260-
```nushell
260+
```nu
261261
def "date info" [] {
262262
let day = $in
263263
print ($day | format date '%v')
@@ -400,7 +400,7 @@ Are one and the same.
400400
::: tip Note
401401
The phrase _"are one and the same"_ above only applies to the graphical output in the shell, it does not mean the two data structures are the same:
402402

403-
```nushell
403+
```nu
404404
(ls) == (ls | table)
405405
# => false
406406
```

book/testing.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Nushell provides a set of "assertion" commands in the standard library.
66
One could use built-in equality / order tests such as `==` or `<=` or more complex commands and throw errors manually when an expected condition fails, but using what the standard library has to offer is arguably easier!
77

88
In the following, it will be assumed that the `std assert` module has been imported inside the current scope
9-
```nushell
9+
```nu
1010
use std assert
1111
```
1212

@@ -132,7 +132,7 @@ The convention is that any command fully exported from the `tests` module will b
132132
If your Nushell script or module is not part of a [Nupm] package, the simplest way is to write tests in standalone scripts and then call them, either from a `Makefile` or in a CI:
133133

134134
Let's say we have a simple `math.nu` module which contains a simple Fibonacci command:
135-
```nushell
135+
```nu
136136
# `fib n` is the n-th Fibonacci number
137137
export def fib [n: int] [ nothing -> int ] {
138138
if $n == 0 {
@@ -145,7 +145,7 @@ export def fib [n: int] [ nothing -> int ] {
145145
}
146146
```
147147
then a test script called `tests.nu` could look like
148-
```nushell
148+
```nu
149149
use math.nu fib
150150
use std assert
151151
@@ -171,7 +171,7 @@ It is also possible to define tests in Nushell as functions with descriptive nam
171171
them dynamically without requiring a [Nupm] package. The following uses `scope commands` and a
172172
second instance of Nushell to run the generated list of tests.
173173

174-
```nushell
174+
```nu
175175
use std assert
176176
177177
source fib.nu

0 commit comments

Comments
 (0)