You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: book/pipelines.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -64,13 +64,13 @@ Compare the following two command-lines that create a directory with tomorrow's
64
64
65
65
Using subexpressions:
66
66
67
-
```nushell
67
+
```nu
68
68
mkdir $'((date now) + 1day | format date '%F') Report'
69
69
```
70
70
71
71
or using pipelines:
72
72
73
-
```nushell
73
+
```nu
74
74
date now # 1: today
75
75
| $in + 1day # 2: tomorrow
76
76
| 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:
95
95
96
96
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:
97
97
98
-
```nushell
98
+
```nu
99
99
1..10 | each {$in * 2}
100
100
```
101
101
102
102
Rather than referring to the entire range of 10 digits, the `each` filter modifies `$in` to refer to the value of the _current iteration_.
103
103
104
104
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:
105
105
106
-
```nushell
106
+
```nu
107
107
1..10 | each {|value| $value * 2}
108
108
```
109
109
110
110
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:
111
111
112
-
```nushell
112
+
```nu
113
113
ls | update name {|file| $file.name | str upcase}
114
114
ls | update name {str upcase}
115
115
```
@@ -257,7 +257,7 @@ While `$in` can be reused as demonstrated above, assigning its value to another
257
257
258
258
Example:
259
259
260
-
```nushell
260
+
```nu
261
261
def "date info" [] {
262
262
let day = $in
263
263
print ($day | format date '%v')
@@ -400,7 +400,7 @@ Are one and the same.
400
400
::: tip Note
401
401
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:
Copy file name to clipboardExpand all lines: book/testing.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ Nushell provides a set of "assertion" commands in the standard library.
6
6
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!
7
7
8
8
In the following, it will be assumed that the `std assert` module has been imported inside the current scope
9
-
```nushell
9
+
```nu
10
10
use std assert
11
11
```
12
12
@@ -132,7 +132,7 @@ The convention is that any command fully exported from the `tests` module will b
132
132
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:
133
133
134
134
Let's say we have a simple `math.nu` module which contains a simple Fibonacci command:
0 commit comments