mirror of
https://github.com/nushell/nushell
synced 2025-01-28 04:45:18 +00:00
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:
parent
7debb27d78
commit
f3626f7c3a
8 changed files with 59 additions and 21 deletions
|
@ -20,7 +20,7 @@ impl Command for Open {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(&self) -> &str {
|
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 {
|
fn signature(&self) -> nu_protocol::Signature {
|
||||||
|
@ -172,6 +172,11 @@ impl Command for Open {
|
||||||
example: "echo 'myfile.txt' | open",
|
example: "echo 'myfile.txt' | open",
|
||||||
result: None,
|
result: None,
|
||||||
},
|
},
|
||||||
|
Example {
|
||||||
|
description: "Open a file, and decode it by the specified encoding",
|
||||||
|
example: "open myfile.txt --raw | decode utf-8",
|
||||||
|
result: None,
|
||||||
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,14 @@ impl Command for Decode {
|
||||||
.category(Category::Strings)
|
.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> {
|
fn examples(&self) -> Vec<Example> {
|
||||||
vec![Example {
|
vec![Example {
|
||||||
description: "Decode the output of an external command",
|
description: "Decode the output of an external command",
|
||||||
|
|
|
@ -8,16 +8,21 @@ Sets a default row's column if missing.
|
||||||
|
|
||||||
## Signature
|
## Signature
|
||||||
|
|
||||||
```> default (column name) (column value)```
|
```> default (default value) (column name)```
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
|
|
||||||
|
- `default value`: the value to use as a default
|
||||||
- `column name`: the name of the column
|
- `column name`: the name of the column
|
||||||
- `column value`: the value of the column to default
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
Give a default 'target' to all file entries
|
Give a default 'target' column to all file entries
|
||||||
```shell
|
```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
|
||||||
```
|
```
|
||||||
|
|
|
@ -27,3 +27,8 @@ Run the block and ignore errors
|
||||||
```shell
|
```shell
|
||||||
> do -i { thisisnotarealcommand }
|
> do -i { thisisnotarealcommand }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Run the block, with a positional parameter
|
||||||
|
```shell
|
||||||
|
> do {|x| 100 + $x } 50
|
||||||
|
```
|
||||||
|
|
|
@ -8,26 +8,25 @@ Check for empty values.
|
||||||
|
|
||||||
## Signature
|
## Signature
|
||||||
|
|
||||||
```> empty? ...rest --block```
|
```> empty? ...rest```
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
|
|
||||||
- `...rest`: the names of the columns to check emptiness
|
- `...rest`: the names of the columns to check emptiness
|
||||||
- `--block {block}`: an optional block to replace if empty
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
Check if a value is empty
|
Check if a string is empty
|
||||||
```shell
|
```shell
|
||||||
> '' | empty?
|
> '' | empty?
|
||||||
```
|
```
|
||||||
|
|
||||||
more than one column
|
Check if a list is empty
|
||||||
|
```shell
|
||||||
|
> [] | empty?
|
||||||
|
```
|
||||||
|
|
||||||
|
Check if more than one column are empty
|
||||||
```shell
|
```shell
|
||||||
> [[meal size]; [arepa small] [taco '']] | empty? meal size
|
> [[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
11
docs/commands/match.md
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
title: match
|
||||||
|
layout: command
|
||||||
|
version: 0.59.1
|
||||||
|
---
|
||||||
|
|
||||||
|
Deprecated command
|
||||||
|
|
||||||
|
## Signature
|
||||||
|
|
||||||
|
```> match ```
|
|
@ -4,7 +4,7 @@ layout: command
|
||||||
version: 0.59.1
|
version: 0.59.1
|
||||||
---
|
---
|
||||||
|
|
||||||
Opens a file.
|
Load a file into a cell, converting to table if possible (avoid by appending '--raw').
|
||||||
|
|
||||||
## Signature
|
## Signature
|
||||||
|
|
||||||
|
@ -31,3 +31,8 @@ Open a file, using the input to get filename
|
||||||
```shell
|
```shell
|
||||||
> echo 'myfile.txt' | open
|
> echo 'myfile.txt' | open
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Open a file, and decode it by the specified encoding
|
||||||
|
```shell
|
||||||
|
> open myfile.txt --raw | decode utf-8
|
||||||
|
```
|
||||||
|
|
|
@ -36,10 +36,10 @@ Replace selected characters in a string with 'X'
|
||||||
Find the longest string and its index
|
Find the longest string and its index
|
||||||
```shell
|
```shell
|
||||||
> [ one longest three bar ] | reduce -n { |it, acc|
|
> [ one longest three bar ] | reduce -n { |it, acc|
|
||||||
if ($it.item | str length) > ($acc | str length) {
|
if ($it.item | str length) > ($acc | str length) {
|
||||||
$it.item
|
$it.item
|
||||||
} else {
|
} else {
|
||||||
$acc
|
$acc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in a new issue