diff --git a/crates/nu-command/src/filesystem/open.rs b/crates/nu-command/src/filesystem/open.rs index f2d47c5cb..c54261df5 100644 --- a/crates/nu-command/src/filesystem/open.rs +++ b/crates/nu-command/src/filesystem/open.rs @@ -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, + }, ] } } diff --git a/crates/nu-command/src/strings/decode.rs b/crates/nu-command/src/strings/decode.rs index 5f9322718..d1920dc8b 100644 --- a/crates/nu-command/src/strings/decode.rs +++ b/crates/nu-command/src/strings/decode.rs @@ -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 { vec![Example { description: "Decode the output of an external command", diff --git a/docs/commands/default.md b/docs/commands/default.md index b79a9fce3..2d9559b5b 100644 --- a/docs/commands/default.md +++ b/docs/commands/default.md @@ -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 ``` diff --git a/docs/commands/do.md b/docs/commands/do.md index 91d1fbc2d..973ca400b 100644 --- a/docs/commands/do.md +++ b/docs/commands/do.md @@ -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 +``` diff --git a/docs/commands/empty.md b/docs/commands/empty.md index b2c459628..ce3a1a849 100644 --- a/docs/commands/empty.md +++ b/docs/commands/empty.md @@ -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] } -``` diff --git a/docs/commands/match.md b/docs/commands/match.md new file mode 100644 index 000000000..6235261f6 --- /dev/null +++ b/docs/commands/match.md @@ -0,0 +1,11 @@ +--- +title: match +layout: command +version: 0.59.1 +--- + +Deprecated command + +## Signature + +```> match ``` diff --git a/docs/commands/open.md b/docs/commands/open.md index 7db5672b8..bbbd143e3 100644 --- a/docs/commands/open.md +++ b/docs/commands/open.md @@ -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 +``` diff --git a/docs/commands/reduce.md b/docs/commands/reduce.md index 55299b14f..eda659331 100644 --- a/docs/commands/reduce.md +++ b/docs/commands/reduce.md @@ -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 + } + } ```