From 0d82d7df602dea0e27ff68352157988cdda2b5d4 Mon Sep 17 00:00:00 2001 From: Justin Ma Date: Wed, 9 Mar 2022 21:05:35 +0800 Subject: [PATCH] Update documents for commands (#4796) * Update documents of commands * Change plugin names for register command examples * Remove unused docs [ci skip] --- .../nu-command/src/core_commands/register.rs | 8 ++--- docs/commands/each_group.md | 23 --------------- docs/commands/each_window.md | 29 ------------------- docs/commands/group.md | 22 ++++++++++++++ docs/commands/gstat.md | 2 +- docs/commands/par-each_group.md | 23 --------------- docs/commands/post.md | 5 ++++ docs/commands/register.md | 8 ++--- docs/commands/save.md | 3 +- docs/commands/str_contains.md | 13 ++++++++- docs/commands/window.md | 28 ++++++++++++++++++ 11 files changed, 78 insertions(+), 86 deletions(-) delete mode 100644 docs/commands/each_group.md delete mode 100644 docs/commands/each_window.md create mode 100644 docs/commands/group.md delete mode 100644 docs/commands/par-each_group.md create mode 100644 docs/commands/window.md diff --git a/crates/nu-command/src/core_commands/register.rs b/crates/nu-command/src/core_commands/register.rs index 22015b2176..bc9829a9ce 100644 --- a/crates/nu-command/src/core_commands/register.rs +++ b/crates/nu-command/src/core_commands/register.rs @@ -54,13 +54,13 @@ impl Command for Register { fn examples(&self) -> Vec { vec![ Example { - description: "Register `nu_plugin_extra_query` plugin from ~/.cargo/bin/ dir", - example: r#"register -e capnp ~/.cargo/bin/nu_plugin_extra_query"#, + description: "Register `nu_plugin_query` plugin from ~/.cargo/bin/ dir", + example: r#"register -e capnp ~/.cargo/bin/nu_plugin_query"#, result: None, }, Example { - description: "Register `nu_plugin_extra_query` plugin from `nu -c`(plugin will be available in that nu session only)", - example: r#"let plugin = ((which nu).path.0 | path dirname | path join 'nu_plugin_extra_query'); nu -c $'register -e capnp ($plugin); version'"#, + description: "Register `nu_plugin_query` plugin from `nu -c`(plugin will be available in that nu session only)", + example: r#"let plugin = ((which nu).path.0 | path dirname | path join 'nu_plugin_query'); nu -c $'register -e capnp ($plugin); version'"#, result: None, }, ] diff --git a/docs/commands/each_group.md b/docs/commands/each_group.md deleted file mode 100644 index c49f59962c..0000000000 --- a/docs/commands/each_group.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -title: each group -layout: command -version: 0.59.1 ---- - -Runs a block on groups of `group_size` rows of a table at a time. - -## Signature - -```> each group (group_size) (block)``` - -## Parameters - - - `group_size`: the size of each group - - `block`: the block to run on each group - -## Examples - -Echo the sum of each pair -```shell -> echo [1 2 3 4] | each group 2 { |it| $it.0 + $it.1 } -``` diff --git a/docs/commands/each_window.md b/docs/commands/each_window.md deleted file mode 100644 index ba80fcad97..0000000000 --- a/docs/commands/each_window.md +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: each window -layout: command -version: 0.59.1 ---- - -Runs a block on window groups of `window_size` that slide by n rows. - -## Signature - -```> each window (window_size) (block) --stride``` - -## Parameters - - - `window_size`: the size of each window - - `block`: the block to run on each window - - `--stride {int}`: the number of rows to slide over between windows - -## Examples - -A sliding window of two elements -```shell -> echo [1 2 3 4] | each window 2 { |it| $it.0 + $it.1 } -``` - -A sliding window of two elements, with a stride of 3 -```shell -> [1, 2, 3, 4, 5, 6, 7, 8] | each window 2 --stride 3 { |x| $x.0 + $x.1 } -``` diff --git a/docs/commands/group.md b/docs/commands/group.md new file mode 100644 index 0000000000..83fb88f6d8 --- /dev/null +++ b/docs/commands/group.md @@ -0,0 +1,22 @@ +--- +title: group +layout: command +version: 0.59.1 +--- + +Groups input into groups of `group_size`. + +## Signature + +```> group (group_size)``` + +## Parameters + + - `group_size`: the size of each group + +## Examples + +Group the a list by pairs +```shell +> echo [1 2 3 4] | group 2 +``` diff --git a/docs/commands/gstat.md b/docs/commands/gstat.md index 1b0138bf01..0fc7353a5a 100644 --- a/docs/commands/gstat.md +++ b/docs/commands/gstat.md @@ -1,7 +1,7 @@ --- title: gstat layout: command -version: 0.59.0 +version: 0.59.1 --- Get the git status of a repo diff --git a/docs/commands/par-each_group.md b/docs/commands/par-each_group.md deleted file mode 100644 index f095b73ef7..0000000000 --- a/docs/commands/par-each_group.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -title: par-each group -layout: command -version: 0.59.1 ---- - -Runs a block on groups of `group_size` rows of a table at a time. - -## Signature - -```> par-each group (group_size) (block)``` - -## Parameters - - - `group_size`: the size of each group - - `block`: the block to run on each group - -## Examples - -Multiplies elements in list -```shell -> echo [1 2 3 4] | par-each group 2 {|it| $it.0 + $it.1 } -``` diff --git a/docs/commands/post.md b/docs/commands/post.md index 30fcfa6e35..e5a781fb0b 100644 --- a/docs/commands/post.md +++ b/docs/commands/post.md @@ -38,3 +38,8 @@ Post content to url.com, with custom header ```shell > post -H [my-header-key my-header-value] url.com ``` + +Post content to url.com with a json body +```shell +> post -t application/json url.com { field: value } +``` diff --git a/docs/commands/register.md b/docs/commands/register.md index e34d782dc7..d40aa5baef 100644 --- a/docs/commands/register.md +++ b/docs/commands/register.md @@ -19,12 +19,12 @@ Register a plugin ## Examples -Register `nu_plugin_extra_query` plugin from ~/.cargo/bin/ dir +Register `nu_plugin_query` plugin from ~/.cargo/bin/ dir ```shell -> register -e capnp ~/.cargo/bin/nu_plugin_extra_query +> register -e capnp ~/.cargo/bin/nu_plugin_query ``` -Register `nu_plugin_extra_query` plugin from `nu -c`(plugin will be available in that nu session only) +Register `nu_plugin_query` plugin from `nu -c`(plugin will be available in that nu session only) ```shell -> let plugin = ((which nu).path.0 | path dirname | path join 'nu_plugin_extra_query'); nu -c $'register -e capnp ($plugin); version' +> let plugin = ((which nu).path.0 | path dirname | path join 'nu_plugin_query'); nu -c $'register -e capnp ($plugin); version' ``` diff --git a/docs/commands/save.md b/docs/commands/save.md index ce335af24c..5f379572df 100644 --- a/docs/commands/save.md +++ b/docs/commands/save.md @@ -8,12 +8,13 @@ Save a file. ## Signature -```> save (filename) --raw``` +```> save (filename) --raw --append``` ## Parameters - `filename`: the filename to use - `--raw`: save file as raw binary + - `--append`: append input to the end of the file ## Examples diff --git a/docs/commands/str_contains.md b/docs/commands/str_contains.md index aa105cf917..929353c34d 100644 --- a/docs/commands/str_contains.md +++ b/docs/commands/str_contains.md @@ -8,13 +8,14 @@ Checks if string contains pattern ## Signature -```> str contains (pattern) ...rest --insensitive``` +```> str contains (pattern) ...rest --insensitive --not``` ## Parameters - `pattern`: the pattern to find - `...rest`: optionally check if string contains pattern by column paths - `--insensitive`: search is case insensitive + - `--not`: does not contain ## Examples @@ -47,3 +48,13 @@ Check if string contains pattern ```shell > 'hello' | str contains 'banana' ``` + +Check if list contains pattern +```shell +> [one two three] | str contains o +``` + +Check if list does not contain pattern +```shell +> [one two three] | str contains -n o +``` diff --git a/docs/commands/window.md b/docs/commands/window.md new file mode 100644 index 0000000000..ffaaa6e788 --- /dev/null +++ b/docs/commands/window.md @@ -0,0 +1,28 @@ +--- +title: window +layout: command +version: 0.59.1 +--- + +Creates a sliding window of `window_size` that slide by n rows/elements across input. + +## Signature + +```> window (window_size) --stride``` + +## Parameters + + - `window_size`: the size of each window + - `--stride {int}`: the number of rows to slide over between windows + +## Examples + +A sliding window of two elements +```shell +> echo [1 2 3 4] | window 2 +``` + +A sliding window of two elements, with a stride of 3 +```shell +> [1, 2, 3, 4, 5, 6, 7, 8] | window 2 --stride 3 +```