From e6570b41ca9c1d1ddc814cbefee8089b8cee60c8 Mon Sep 17 00:00:00 2001 From: Justin Ma Date: Fri, 25 Feb 2022 21:14:15 +0800 Subject: [PATCH] Fix some examples and regenerate docs, should fix: #4455 (#4639) --- crates/nu-command/src/filters/compact.rs | 2 +- crates/nu-command/src/hash/base64.rs | 2 +- docs/commands/compact.md | 2 +- docs/commands/export.md | 7 +++++++ docs/commands/extern.md | 7 +++++++ docs/commands/hash_base64.md | 2 +- docs/commands/run-external.md | 7 +++++++ 7 files changed, 25 insertions(+), 4 deletions(-) diff --git a/crates/nu-command/src/filters/compact.rs b/crates/nu-command/src/filters/compact.rs index 184f90976..3cf99312d 100644 --- a/crates/nu-command/src/filters/compact.rs +++ b/crates/nu-command/src/filters/compact.rs @@ -59,7 +59,7 @@ impl Command for Compact { }), }, Example { - description: "Filter out all instances of nothing from a list (Returns [1,2]", + description: "Filter out all instances of nothing from a list (Returns [1,2])", example: r#"echo [1, $nothing, 2] | compact"#, result: Some(Value::List { vals: vec![Value::test_int(1), Value::test_int(2)], diff --git a/crates/nu-command/src/hash/base64.rs b/crates/nu-command/src/hash/base64.rs index 7cf563e1b..e21527412 100644 --- a/crates/nu-command/src/hash/base64.rs +++ b/crates/nu-command/src/hash/base64.rs @@ -66,7 +66,7 @@ impl Command for Base64 { }, Example { description: "Base64 encode a string with the binhex character set", - example: "echo 'username:password' | hash base64 --character_set binhex --encode", + example: "echo 'username:password' | hash base64 --character-set binhex --encode", result: Some(Value::string("F@0NEPjJD97kE'&bEhFZEP3", Span::test_data())), }, Example { diff --git a/docs/commands/compact.md b/docs/commands/compact.md index 54f99847a..e40f27a19 100644 --- a/docs/commands/compact.md +++ b/docs/commands/compact.md @@ -26,7 +26,7 @@ Filter out all records where 'World' is null (Returns the table) > echo [["Hello" "World"]; [$nothing 3]]| compact World ``` -Filter out all instances of nothing from a list (Returns [1,2] +Filter out all instances of nothing from a list (Returns [1,2]) ```shell > echo [1, $nothing, 2] | compact ``` diff --git a/docs/commands/export.md b/docs/commands/export.md index b70bfb4c9..f50532ff2 100644 --- a/docs/commands/export.md +++ b/docs/commands/export.md @@ -9,3 +9,10 @@ Export custom commands or environment variables from a module. ## Signature ```> export ``` + +## Examples + +Export a definition from a module +```shell +> module utils { export def my-command [] { "hello" } }; use utils my-command; my-command +``` diff --git a/docs/commands/extern.md b/docs/commands/extern.md index f80834c39..84376cced 100644 --- a/docs/commands/extern.md +++ b/docs/commands/extern.md @@ -14,3 +14,10 @@ Define a signature for an external command - `def_name`: definition name - `params`: parameters + +## Examples + +Write a signature for an external command +```shell +> extern echo [text: string] +``` diff --git a/docs/commands/hash_base64.md b/docs/commands/hash_base64.md index f0ee5f3a2..3c95aa16e 100644 --- a/docs/commands/hash_base64.md +++ b/docs/commands/hash_base64.md @@ -27,7 +27,7 @@ Base64 encode a string with default settings Base64 encode a string with the binhex character set ```shell -> echo 'username:password' | hash base64 --character_set binhex --encode +> echo 'username:password' | hash base64 --character-set binhex --encode ``` Base64 decode a value diff --git a/docs/commands/run-external.md b/docs/commands/run-external.md index ce433f2b5..0594255e4 100644 --- a/docs/commands/run-external.md +++ b/docs/commands/run-external.md @@ -15,3 +15,10 @@ Runs external command - `...rest`: external command to run - `--redirect-stdout`: redirect-stdout - `--redirect-stderr`: redirect-stderr + +## Examples + +Run an external command +```shell +> run-external "echo" "-n" "hello" +```