mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 16:33:37 +01:00
feat: fix and update some examples (#4844)
This commit is contained in:
parent
54d9fff4f2
commit
10d805c1fa
@ -224,6 +224,22 @@ impl Command for Ls {
|
|||||||
example: "ls *.rs",
|
example: "ls *.rs",
|
||||||
result: None,
|
result: None,
|
||||||
},
|
},
|
||||||
|
Example {
|
||||||
|
description: "List all files and directories whose name do not contain 'bar'",
|
||||||
|
example: "ls -s | where name !~ bar",
|
||||||
|
result: None,
|
||||||
|
},
|
||||||
|
Example {
|
||||||
|
description: "List all dirs with full path name in your home directory",
|
||||||
|
example: "ls -f ~ | where type == dir",
|
||||||
|
result: None,
|
||||||
|
},
|
||||||
|
Example {
|
||||||
|
description:
|
||||||
|
"List all dirs in your home directory which have not been modified in 7 days",
|
||||||
|
example: "ls -s ~ | where type == dir && modified < ((date now) - 7day)",
|
||||||
|
result: None,
|
||||||
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,14 @@ impl Command for Reduce {
|
|||||||
span: Span::test_data(),
|
span: Span::test_data(),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
Example {
|
||||||
|
example: "[ 1 2 3 ] | reduce -n {|it, acc| $acc + $it.item }",
|
||||||
|
description: "Sum values of a list (same as 'math sum')",
|
||||||
|
result: Some(Value::Int {
|
||||||
|
val: 6,
|
||||||
|
span: Span::test_data(),
|
||||||
|
}),
|
||||||
|
},
|
||||||
Example {
|
Example {
|
||||||
example: "[ 1 2 3 4 ] | reduce -f 10 {|it, acc| $acc + $it }",
|
example: "[ 1 2 3 4 ] | reduce -f 10 {|it, acc| $acc + $it }",
|
||||||
description: "Sum values with a starting value (fold)",
|
description: "Sum values with a starting value (fold)",
|
||||||
|
@ -96,7 +96,7 @@ impl Command for Where {
|
|||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "List all files that were modified in the last two weeks",
|
description: "List all files that were modified in the last two weeks",
|
||||||
example: "ls | where modified <= 2wk",
|
example: "ls | where modified >= (date now) - 2wk",
|
||||||
result: None,
|
result: None,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
@ -35,3 +35,18 @@ List all rust files
|
|||||||
```shell
|
```shell
|
||||||
> ls *.rs
|
> ls *.rs
|
||||||
```
|
```
|
||||||
|
|
||||||
|
List all files and directories whose name do not contain 'bar'
|
||||||
|
```shell
|
||||||
|
> ls -s | where name !~ bar
|
||||||
|
```
|
||||||
|
|
||||||
|
List all dirs with full path name in your home directory
|
||||||
|
```shell
|
||||||
|
> ls -f ~ | where type == dir
|
||||||
|
```
|
||||||
|
|
||||||
|
List all dirs in your home directory which have not been modified in 7 days
|
||||||
|
```shell
|
||||||
|
> ls -s ~ | where type == dir && modified < ((date now) - 7day)
|
||||||
|
```
|
||||||
|
@ -23,6 +23,11 @@ Sum values of a list (same as 'math sum')
|
|||||||
> [ 1 2 3 4 ] | reduce {|it, acc| $it + $acc }
|
> [ 1 2 3 4 ] | reduce {|it, acc| $it + $acc }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Sum values of a list (same as 'math sum')
|
||||||
|
```shell
|
||||||
|
> [ 1 2 3 ] | reduce -n {|it, acc| $acc + $it.item }
|
||||||
|
```
|
||||||
|
|
||||||
Sum values with a starting value (fold)
|
Sum values with a starting value (fold)
|
||||||
```shell
|
```shell
|
||||||
> [ 1 2 3 4 ] | reduce -f 10 {|it, acc| $acc + $it }
|
> [ 1 2 3 4 ] | reduce -f 10 {|it, acc| $acc + $it }
|
||||||
|
@ -33,5 +33,5 @@ List all files with names that contain "Car"
|
|||||||
|
|
||||||
List all files that were modified in the last two weeks
|
List all files that were modified in the last two weeks
|
||||||
```shell
|
```shell
|
||||||
> ls | where modified <= 2wk
|
> ls | where modified >= (date now) - 2wk
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user