feat: fix and update some examples (#4844)

This commit is contained in:
Justin Ma 2022-03-14 20:41:09 +08:00 committed by GitHub
parent 54d9fff4f2
commit 10d805c1fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 46 additions and 2 deletions

View File

@ -224,6 +224,22 @@ impl Command for Ls {
example: "ls *.rs",
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,
},
]
}
}

View File

@ -46,6 +46,14 @@ impl Command for Reduce {
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: "[ 1 2 3 4 ] | reduce -f 10 {|it, acc| $acc + $it }",
description: "Sum values with a starting value (fold)",

View File

@ -96,7 +96,7 @@ impl Command for Where {
},
Example {
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,
},
]

View File

@ -35,3 +35,18 @@ List all rust files
```shell
> 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)
```

View File

@ -23,6 +23,11 @@ Sum values of a list (same as 'math sum')
> [ 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)
```shell
> [ 1 2 3 4 ] | reduce -f 10 {|it, acc| $acc + $it }

View File

@ -33,5 +33,5 @@ List all files with names that contain "Car"
List all files that were modified in the last two weeks
```shell
> ls | where modified <= 2wk
> ls | where modified >= (date now) - 2wk
```