Update docs for open and decode command, regenerate all docs (#4815)

* Update docs for open and decode command, regenerate all docs

* Update open.rs

* Update open.md

Co-authored-by: JT <547158+jntrnr@users.noreply.github.com>
This commit is contained in:
Justin Ma 2022-03-11 18:39:54 +08:00 committed by GitHub
parent 7debb27d78
commit f3626f7c3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 59 additions and 21 deletions

View File

@ -20,7 +20,7 @@ impl Command for Open {
}
fn usage(&self) -> &str {
"Opens a file."
"Load a file into a cell, converting to table if possible (avoid by appending '--raw')."
}
fn signature(&self) -> nu_protocol::Signature {
@ -172,6 +172,11 @@ impl Command for Open {
example: "echo 'myfile.txt' | open",
result: None,
},
Example {
description: "Open a file, and decode it by the specified encoding",
example: "open myfile.txt --raw | decode utf-8",
result: None,
},
]
}
}

View File

@ -25,6 +25,14 @@ impl Command for Decode {
.category(Category::Strings)
}
fn extra_usage(&self) -> &str {
r#"Multiple encodings are supported, here is an example of a few:
big5, euc-jp, euc-kr, gbk, iso-8859-1, utf-16, cp1252, latin5
For a more complete list of encodings please refer to the encoding_rs
documentation link at https://docs.rs/encoding_rs/0.8.28/encoding_rs/#statics"#
}
fn examples(&self) -> Vec<Example> {
vec![Example {
description: "Decode the output of an external command",

View File

@ -8,16 +8,21 @@ Sets a default row's column if missing.
## Signature
```> default (column name) (column value)```
```> default (default value) (column name)```
## Parameters
- `default value`: the value to use as a default
- `column name`: the name of the column
- `column value`: the value of the column to default
## Examples
Give a default 'target' to all file entries
Give a default 'target' column to all file entries
```shell
> ls -la | default target 'nothing'
> ls -la | default 'nothing' target
```
Default the `$nothing` value in a list
```shell
> [1, 2, $nothing, 4] | default 3
```

View File

@ -27,3 +27,8 @@ Run the block and ignore errors
```shell
> do -i { thisisnotarealcommand }
```
Run the block, with a positional parameter
```shell
> do {|x| 100 + $x } 50
```

View File

@ -8,26 +8,25 @@ Check for empty values.
## Signature
```> empty? ...rest --block```
```> empty? ...rest```
## Parameters
- `...rest`: the names of the columns to check emptiness
- `--block {block}`: an optional block to replace if empty
## Examples
Check if a value is empty
Check if a string is empty
```shell
> '' | empty?
```
more than one column
Check if a list is empty
```shell
> [] | empty?
```
Check if more than one column are empty
```shell
> [[meal size]; [arepa small] [taco '']] | empty? meal size
```
use a block if setting the empty cell contents is wanted
```shell
> [[2020/04/16 2020/07/10 2020/11/16]; ['' [27] [37]]] | empty? 2020/04/16 -b { |_| [33 37] }
```

11
docs/commands/match.md Normal file
View File

@ -0,0 +1,11 @@
---
title: match
layout: command
version: 0.59.1
---
Deprecated command
## Signature
```> match ```

View File

@ -4,7 +4,7 @@ layout: command
version: 0.59.1
---
Opens a file.
Load a file into a cell, converting to table if possible (avoid by appending '--raw').
## Signature
@ -31,3 +31,8 @@ Open a file, using the input to get filename
```shell
> echo 'myfile.txt' | open
```
Open a file, and decode it by the specified encoding
```shell
> open myfile.txt --raw | decode utf-8
```

View File

@ -36,10 +36,10 @@ Replace selected characters in a string with 'X'
Find the longest string and its index
```shell
> [ one longest three bar ] | reduce -n { |it, acc|
if ($it.item | str length) > ($acc | str length) {
$it.item
} else {
$acc
}
}
if ($it.item | str length) > ($acc | str length) {
$it.item
} else {
$acc
}
}
```