mirror of
https://github.com/nushell/nushell
synced 2025-01-13 05:38:57 +00:00
Further edits to help messages (#6913)
This commit is contained in:
parent
902aad6016
commit
5add5cbd12
34 changed files with 113 additions and 73 deletions
|
@ -49,10 +49,17 @@ impl Command for Alias {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn examples(&self) -> Vec<Example> {
|
fn examples(&self) -> Vec<Example> {
|
||||||
vec![Example {
|
vec![
|
||||||
|
Example {
|
||||||
description: "Alias ll to ls -l",
|
description: "Alias ll to ls -l",
|
||||||
example: "alias ll = ls -l",
|
example: "alias ll = ls -l",
|
||||||
result: None,
|
result: None,
|
||||||
}]
|
},
|
||||||
|
Example {
|
||||||
|
description: "Make an alias that makes a list of all custom commands",
|
||||||
|
example: "alias customs = ($nu.scope.commands | where is_custom | get command)",
|
||||||
|
result: None,
|
||||||
|
},
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ use nu_engine::CallExt;
|
||||||
use nu_protocol::ast::Call;
|
use nu_protocol::ast::Call;
|
||||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
Category, Example, ListStream, PipelineData, ShellError, Signature, SyntaxShape, Value,
|
Category, Example, ListStream, PipelineData, ShellError, Signature, Span, SyntaxShape, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -14,7 +14,7 @@ impl Command for Echo {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(&self) -> &str {
|
fn usage(&self) -> &str {
|
||||||
"Echo the arguments back to the user."
|
"Returns its arguments, ignoring the piped-in value."
|
||||||
}
|
}
|
||||||
|
|
||||||
fn signature(&self) -> Signature {
|
fn signature(&self) -> Signature {
|
||||||
|
@ -24,7 +24,9 @@ impl Command for Echo {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extra_usage(&self) -> &str {
|
fn extra_usage(&self) -> &str {
|
||||||
"Unlike `print`, this command returns an actual value that will be passed to the next command of the pipeline."
|
r#"When given no arguments, it returns an empty string. When given one argument,
|
||||||
|
it returns it. Otherwise, it returns a list of the arguments. There is usually
|
||||||
|
little reason to use this over just writing the values as-is."#
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run(
|
fn run(
|
||||||
|
@ -61,13 +63,17 @@ impl Command for Echo {
|
||||||
fn examples(&self) -> Vec<Example> {
|
fn examples(&self) -> Vec<Example> {
|
||||||
vec![
|
vec![
|
||||||
Example {
|
Example {
|
||||||
description: "Put a hello message in the pipeline",
|
description: "Put a list of numbers in the pipeline. This is the same as [1 2 3].",
|
||||||
example: "echo 'hello'",
|
example: "echo 1 2 3",
|
||||||
result: Some(Value::test_string("hello")),
|
result: Some(Value::List {
|
||||||
|
vals: vec![Value::test_int(1), Value::test_int(2), Value::test_int(3)],
|
||||||
|
span: Span::test_data(),
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "Print the value of the special '$nu' variable",
|
description:
|
||||||
example: "echo $nu",
|
"Returns the piped-in value, by using the special $in variable to obtain it.",
|
||||||
|
example: "echo $in",
|
||||||
result: None,
|
result: None,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
|
@ -105,7 +105,7 @@ impl Command for OverlayHide {
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "Hide an overlay created from a file",
|
description: "Hide an overlay created from a file",
|
||||||
example: r#"echo 'export alias f = "foo"' | save spam.nu
|
example: r#"'export alias f = "foo"' | save spam.nu
|
||||||
overlay use spam.nu
|
overlay use spam.nu
|
||||||
overlay hide spam"#,
|
overlay hide spam"#,
|
||||||
result: None,
|
result: None,
|
||||||
|
|
|
@ -183,14 +183,14 @@ impl Command for OverlayUse {
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "Create an overlay with a prefix",
|
description: "Create an overlay with a prefix",
|
||||||
example: r#"echo 'export def foo { "foo" }'
|
example: r#"'export def foo { "foo" }'
|
||||||
overlay use --prefix spam
|
overlay use --prefix spam
|
||||||
spam foo"#,
|
spam foo"#,
|
||||||
result: None,
|
result: None,
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "Create an overlay from a file",
|
description: "Create an overlay from a file",
|
||||||
example: r#"echo 'export-env { let-env FOO = "foo" }' | save spam.nu
|
example: r#"'export-env { let-env FOO = "foo" }' | save spam.nu
|
||||||
overlay use spam.nu
|
overlay use spam.nu
|
||||||
$env.FOO"#,
|
$env.FOO"#,
|
||||||
result: None,
|
result: None,
|
||||||
|
|
|
@ -15,13 +15,12 @@ impl Command for ToDataBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(&self) -> &str {
|
fn usage(&self) -> &str {
|
||||||
"Converts into an open db connection"
|
"Converts the input into an open db connection"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extra_usage(&self) -> &str {
|
fn extra_usage(&self) -> &str {
|
||||||
"This function is used as type hint for parser, specially if the query is not started with 'from table'"
|
"This function is used as a hint to Nushell to optimize the pipeline for database queries."
|
||||||
}
|
}
|
||||||
|
|
||||||
fn signature(&self) -> Signature {
|
fn signature(&self) -> Signature {
|
||||||
Signature::build(self.name())
|
Signature::build(self.name())
|
||||||
.input_type(Type::Any)
|
.input_type(Type::Any)
|
||||||
|
@ -35,7 +34,7 @@ impl Command for ToDataBase {
|
||||||
|
|
||||||
fn examples(&self) -> Vec<Example> {
|
fn examples(&self) -> Vec<Example> {
|
||||||
vec![Example {
|
vec![Example {
|
||||||
description: "Converts an open file into a db object",
|
description: "Converts an open file into a db object.",
|
||||||
example: "open db.sqlite | into db",
|
example: "open db.sqlite | into db",
|
||||||
result: None,
|
result: None,
|
||||||
}]
|
}]
|
||||||
|
|
2
crates/nu-command/src/env/with_env.rs
vendored
2
crates/nu-command/src/env/with_env.rs
vendored
|
@ -63,7 +63,7 @@ impl Command for WithEnv {
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "Set by row(e.g. `open x.json` or `from json`)",
|
description: "Set by row(e.g. `open x.json` or `from json`)",
|
||||||
example: r#"echo '{"X":"Y","W":"Z"}'|from json|with-env $in { echo $env.X $env.W }"#,
|
example: r#"'{"X":"Y","W":"Z"}'|from json|with-env $in { echo $env.X $env.W }"#,
|
||||||
result: None,
|
result: None,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
|
@ -42,12 +42,12 @@ impl Command for Ls {
|
||||||
.switch("all", "Show hidden files", Some('a'))
|
.switch("all", "Show hidden files", Some('a'))
|
||||||
.switch(
|
.switch(
|
||||||
"long",
|
"long",
|
||||||
"List all available columns for each entry",
|
"Get all available columns for each entry (slower; columns are platform-dependent)",
|
||||||
Some('l'),
|
Some('l'),
|
||||||
)
|
)
|
||||||
.switch(
|
.switch(
|
||||||
"short-names",
|
"short-names",
|
||||||
"Only print the file names and not the path",
|
"Only print the file names, and not the path",
|
||||||
Some('s'),
|
Some('s'),
|
||||||
)
|
)
|
||||||
.switch("full-paths", "display paths as absolute paths", Some('f'))
|
.switch("full-paths", "display paths as absolute paths", Some('f'))
|
||||||
|
|
|
@ -265,17 +265,17 @@ impl Command for Save {
|
||||||
vec![
|
vec![
|
||||||
Example {
|
Example {
|
||||||
description: "Save a string to foo.txt in the current directory",
|
description: "Save a string to foo.txt in the current directory",
|
||||||
example: r#"echo 'save me' | save foo.txt"#,
|
example: r#"'save me' | save foo.txt"#,
|
||||||
result: None,
|
result: None,
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "Append a string to the end of foo.txt",
|
description: "Append a string to the end of foo.txt",
|
||||||
example: r#"echo 'append me' | save --append foo.txt"#,
|
example: r#"'append me' | save --append foo.txt"#,
|
||||||
result: None,
|
result: None,
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "Save a record to foo.json in the current directory",
|
description: "Save a record to foo.json in the current directory",
|
||||||
example: r#"echo { a: 1, b: 2 } | save foo.json"#,
|
example: r#"{ a: 1, b: 2 } | save foo.json"#,
|
||||||
result: None,
|
result: None,
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
|
|
|
@ -24,6 +24,13 @@ impl Command for Append {
|
||||||
"Append any number of rows to a table."
|
"Append any number of rows to a table."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn extra_usage(&self) -> &str {
|
||||||
|
r#"Be aware that this command 'unwraps' lists passed to it. So, if you pass a variable to it,
|
||||||
|
and you want the variable's contents to be appended without being unwrapped, it's wise to
|
||||||
|
pre-emptively wrap the variable in a list, like so: `append [$val]`. This way, `append` will
|
||||||
|
only unwrap the outer list, and leave the variable's contents untouched."#
|
||||||
|
}
|
||||||
|
|
||||||
fn search_terms(&self) -> Vec<&str> {
|
fn search_terms(&self) -> Vec<&str> {
|
||||||
vec!["add", "concatenate"]
|
vec!["add", "concatenate"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ impl Command for Compact {
|
||||||
vec![
|
vec![
|
||||||
Example {
|
Example {
|
||||||
description: "Filter out all records where 'Hello' is null (returns nothing)",
|
description: "Filter out all records where 'Hello' is null (returns nothing)",
|
||||||
example: r#"echo [["Hello" "World"]; [$nothing 3]]| compact Hello"#,
|
example: r#"[["Hello" "World"]; [null 3]]| compact Hello"#,
|
||||||
result: Some(Value::List {
|
result: Some(Value::List {
|
||||||
vals: vec![],
|
vals: vec![],
|
||||||
span: Span::test_data(),
|
span: Span::test_data(),
|
||||||
|
@ -48,7 +48,7 @@ impl Command for Compact {
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "Filter out all records where 'World' is null (Returns the table)",
|
description: "Filter out all records where 'World' is null (Returns the table)",
|
||||||
example: r#"echo [["Hello" "World"]; [$nothing 3]]| compact World"#,
|
example: r#"[["Hello" "World"]; [null 3]]| compact World"#,
|
||||||
result: Some(Value::List {
|
result: Some(Value::List {
|
||||||
vals: vec![Value::Record {
|
vals: vec![Value::Record {
|
||||||
cols: vec!["Hello".into(), "World".into()],
|
cols: vec!["Hello".into(), "World".into()],
|
||||||
|
@ -60,7 +60,7 @@ impl Command for Compact {
|
||||||
},
|
},
|
||||||
Example {
|
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"#,
|
example: r#"[1, null, 2] | compact"#,
|
||||||
result: Some(Value::List {
|
result: Some(Value::List {
|
||||||
vals: vec![Value::test_int(1), Value::test_int(2)],
|
vals: vec![Value::test_int(1), Value::test_int(2)],
|
||||||
span: Span::test_data(),
|
span: Span::test_data(),
|
||||||
|
|
|
@ -50,8 +50,8 @@ impl Command for Default {
|
||||||
result: None, // Some(Value::test_string("abc")),
|
result: None, // Some(Value::test_string("abc")),
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "Default the `$nothing` value in a list",
|
description: "Replace the `null` value in a list",
|
||||||
example: "[1, 2, $nothing, 4] | default 3",
|
example: "[1, 2, null, 4] | default 3",
|
||||||
result: Some(Value::List {
|
result: Some(Value::List {
|
||||||
vals: vec![
|
vals: vec![
|
||||||
Value::test_int(1),
|
Value::test_int(1),
|
||||||
|
|
|
@ -16,7 +16,17 @@ impl Command for Each {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(&self) -> &str {
|
fn usage(&self) -> &str {
|
||||||
"Run a block on each element of input"
|
"Run a block on each row of input"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn extra_usage(&self) -> &str {
|
||||||
|
r#"Since tables are lists of records, passing a table into 'each' will
|
||||||
|
iterate over each record, not necessarily each cell within it.
|
||||||
|
|
||||||
|
Avoid passing single records to this command. Since a record is a
|
||||||
|
one-row structure, 'each' will only run once, behaving similar to 'do'.
|
||||||
|
To iterate over a record's values, try converting it to a table
|
||||||
|
with 'transpose' first."#
|
||||||
}
|
}
|
||||||
|
|
||||||
fn search_terms(&self) -> Vec<&str> {
|
fn search_terms(&self) -> Vec<&str> {
|
||||||
|
|
|
@ -15,7 +15,7 @@ impl Command for EachWhile {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(&self) -> &str {
|
fn usage(&self) -> &str {
|
||||||
"Run a block on each element of input until a $nothing is found"
|
"Run a block on each element of input until a null is found"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn search_terms(&self) -> Vec<&str> {
|
fn search_terms(&self) -> Vec<&str> {
|
||||||
|
@ -47,7 +47,7 @@ impl Command for EachWhile {
|
||||||
|
|
||||||
vec![
|
vec![
|
||||||
Example {
|
Example {
|
||||||
example: "[1 2 3] | each while { |it| if $it < 3 {$it} else {$nothing} }",
|
example: "[1 2 3] | each while { |it| if $it < 3 { $it } else { null } }",
|
||||||
description: "Multiplies elements in list",
|
description: "Multiplies elements in list",
|
||||||
result: Some(Value::List {
|
result: Some(Value::List {
|
||||||
vals: stream_test_1,
|
vals: stream_test_1,
|
||||||
|
@ -55,7 +55,7 @@ impl Command for EachWhile {
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
example: r#"[1 2 3] | each while -n { |it| if $it.item < 2 { $"value ($it.item) at ($it.index)!"} else { $nothing } }"#,
|
example: r#"[1 2 3] | each while -n { |it| if $it.item < 2 { $"value ($it.item) at ($it.index)!"} else { null } }"#,
|
||||||
description: "Iterate over each element, print the matching value and its index",
|
description: "Iterate over each element, print the matching value and its index",
|
||||||
result: Some(Value::List {
|
result: Some(Value::List {
|
||||||
vals: vec![Value::String {
|
vals: vec![Value::String {
|
||||||
|
|
|
@ -67,7 +67,7 @@ impl Command for Find {
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "Search for a term in a string",
|
description: "Search for a term in a string",
|
||||||
example: r#"echo Cargo.toml | find toml"#,
|
example: r#"'Cargo.toml' | find toml"#,
|
||||||
result: Some(Value::test_string("Cargo.toml".to_owned()))
|
result: Some(Value::test_string("Cargo.toml".to_owned()))
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
|
|
|
@ -28,6 +28,13 @@ impl Command for Prepend {
|
||||||
"Prepend any number of rows to a table."
|
"Prepend any number of rows to a table."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn extra_usage(&self) -> &str {
|
||||||
|
r#"Be aware that this command 'unwraps' lists passed to it. So, if you pass a variable to it,
|
||||||
|
and you want the variable's contents to be prepended without being unwrapped, it's wise to
|
||||||
|
pre-emptively wrap the variable in a list, like so: `prepend [$val]`. This way, `prepend` will
|
||||||
|
only unwrap the outer list, and leave the variable's contents untouched."#
|
||||||
|
}
|
||||||
|
|
||||||
fn search_terms(&self) -> Vec<&str> {
|
fn search_terms(&self) -> Vec<&str> {
|
||||||
vec!["add", "concatenate"]
|
vec!["add", "concatenate"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ impl Command for Shuffle {
|
||||||
fn examples(&self) -> Vec<Example> {
|
fn examples(&self) -> Vec<Example> {
|
||||||
vec![Example {
|
vec![Example {
|
||||||
description: "Shuffle rows randomly (execute it several times and see the difference)",
|
description: "Shuffle rows randomly (execute it several times and see the difference)",
|
||||||
example: r#"echo [[version patch]; [1.0.0 false] [3.0.1 true] [2.0.0 false]] | shuffle"#,
|
example: r#"[[version patch]; [1.0.0 false] [3.0.1 true] [2.0.0 false]] | shuffle"#,
|
||||||
result: None,
|
result: None,
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,27 +48,27 @@ impl Command for FromTsv {
|
||||||
vec![
|
vec![
|
||||||
Example {
|
Example {
|
||||||
description: "Create a tsv file with header columns and open it",
|
description: "Create a tsv file with header columns and open it",
|
||||||
example: r#"echo $'c1(char tab)c2(char tab)c3(char nl)1(char tab)2(char tab)3' | save tsv-data | open tsv-data | from tsv"#,
|
example: r#"$'c1(char tab)c2(char tab)c3(char nl)1(char tab)2(char tab)3' | save tsv-data | open tsv-data | from tsv"#,
|
||||||
result: None,
|
result: None,
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "Create a tsv file without header columns and open it",
|
description: "Create a tsv file without header columns and open it",
|
||||||
example: r#"echo $'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv -n"#,
|
example: r#"$'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv -n"#,
|
||||||
result: None,
|
result: None,
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "Create a tsv file without header columns and open it, removing all unnecessary whitespaces",
|
description: "Create a tsv file without header columns and open it, removing all unnecessary whitespaces",
|
||||||
example: r#"echo $'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv --trim all"#,
|
example: r#"$'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv --trim all"#,
|
||||||
result: None,
|
result: None,
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "Create a tsv file without header columns and open it, removing all unnecessary whitespaces in the header names",
|
description: "Create a tsv file without header columns and open it, removing all unnecessary whitespaces in the header names",
|
||||||
example: r#"echo $'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv --trim headers"#,
|
example: r#"$'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv --trim headers"#,
|
||||||
result: None,
|
result: None,
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "Create a tsv file without header columns and open it, removing all unnecessary whitespaces in the field values",
|
description: "Create a tsv file without header columns and open it, removing all unnecessary whitespaces in the field values",
|
||||||
example: r#"echo $'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv --trim fields"#,
|
example: r#"$'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv --trim fields"#,
|
||||||
result: None,
|
result: None,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
|
@ -285,14 +285,14 @@ Format: #
|
||||||
Example {
|
Example {
|
||||||
description:
|
description:
|
||||||
"Use ansi to color text (rb = red bold, gb = green bold, pb = purple bold)",
|
"Use ansi to color text (rb = red bold, gb = green bold, pb = purple bold)",
|
||||||
example: r#"echo [(ansi rb) Hello " " (ansi gb) Nu " " (ansi pb) World (ansi reset)] | str join"#,
|
example: r#"$'(ansi rb)Hello (ansi gb)Nu (ansi pb)World(ansi reset)'"#,
|
||||||
result: Some(Value::test_string(
|
result: Some(Value::test_string(
|
||||||
"\u{1b}[1;31mHello \u{1b}[1;32mNu \u{1b}[1;35mWorld\u{1b}[0m",
|
"\u{1b}[1;31mHello \u{1b}[1;32mNu \u{1b}[1;35mWorld\u{1b}[0m",
|
||||||
)),
|
)),
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "Use ansi to color text (italic bright yellow on red 'Hello' with green bold 'Nu' and purple bold 'World')",
|
description: "Use ansi to color text (italic bright yellow on red 'Hello' with green bold 'Nu' and purple bold 'World')",
|
||||||
example: r#"echo [(ansi -e '3;93;41m') Hello (ansi reset) " " (ansi gb) Nu " " (ansi pb) World (ansi reset)] | str join"#,
|
example: r#"[(ansi -e '3;93;41m') Hello (ansi reset) " " (ansi gb) Nu " " (ansi pb) World (ansi reset)] | str join"#,
|
||||||
result: Some(Value::test_string(
|
result: Some(Value::test_string(
|
||||||
"\u{1b}[3;93;41mHello\u{1b}[0m \u{1b}[1;32mNu \u{1b}[1;35mWorld\u{1b}[0m",
|
"\u{1b}[3;93;41mHello\u{1b}[0m \u{1b}[1;32mNu \u{1b}[1;35mWorld\u{1b}[0m",
|
||||||
)),
|
)),
|
||||||
|
|
|
@ -40,7 +40,7 @@ impl Command for SubCommand {
|
||||||
fn examples(&self) -> Vec<Example> {
|
fn examples(&self) -> Vec<Example> {
|
||||||
vec![Example {
|
vec![Example {
|
||||||
description: "Strip ANSI escape sequences from a string",
|
description: "Strip ANSI escape sequences from a string",
|
||||||
example: r#"echo [ (ansi green) (ansi cursor_on) "hello" ] | str join | ansi strip"#,
|
example: r#"$'(ansi green)(ansi cursor_on)hello' | ansi strip"#,
|
||||||
result: Some(Value::test_string("hello")),
|
result: Some(Value::test_string("hello")),
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,8 +184,8 @@ impl Command for Char {
|
||||||
result: Some(Value::test_string("\n")),
|
result: Some(Value::test_string("\n")),
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "Output prompt character, newline and a hamburger character",
|
description: "Output prompt character, newline and a hamburger menu character",
|
||||||
example: r#"echo [(char prompt) (char newline) (char hamburger)] | str join"#,
|
example: r#"(char prompt) + (char newline) + (char hamburger)"#,
|
||||||
result: Some(Value::test_string("\u{25b6}\n\u{2261}")),
|
result: Some(Value::test_string("\u{25b6}\n\u{2261}")),
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
|
|
|
@ -41,7 +41,7 @@ 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: "Encode an UTF-8 string into Shift-JIS",
|
description: "Encode an UTF-8 string into Shift-JIS",
|
||||||
example: r#"echo "負けると知って戦うのが、遥かに美しいのだ" | encode shift-jis"#,
|
example: r#""負けると知って戦うのが、遥かに美しいのだ" | encode shift-jis"#,
|
||||||
result: Some(Value::Binary {
|
result: Some(Value::Binary {
|
||||||
val: vec![
|
val: vec![
|
||||||
0x95, 0x89, 0x82, 0xaf, 0x82, 0xe9, 0x82, 0xc6, 0x92, 0x6d, 0x82, 0xc1, 0x82,
|
0x95, 0x89, 0x82, 0xaf, 0x82, 0xe9, 0x82, 0xc6, 0x92, 0x6d, 0x82, 0xc1, 0x82,
|
||||||
|
|
|
@ -21,7 +21,7 @@ impl Command for StrCollect {
|
||||||
SyntaxShape::String,
|
SyntaxShape::String,
|
||||||
"optional separator to use when creating string",
|
"optional separator to use when creating string",
|
||||||
)
|
)
|
||||||
.category(Category::Strings)
|
.category(Category::Deprecated)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(&self) -> &str {
|
fn usage(&self) -> &str {
|
||||||
|
|
|
@ -165,7 +165,7 @@ impl Command for Table {
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "Render data in table view",
|
description: "Render data in table view",
|
||||||
example: r#"echo [[a b]; [1 2] [3 4]] | table"#,
|
example: r#"[[a b]; [1 2] [3 4]] | table"#,
|
||||||
result: Some(Value::List {
|
result: Some(Value::List {
|
||||||
vals: vec![
|
vals: vec![
|
||||||
Value::Record {
|
Value::Record {
|
||||||
|
@ -184,7 +184,7 @@ impl Command for Table {
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "Render data in table view (expanded)",
|
description: "Render data in table view (expanded)",
|
||||||
example: r#"echo [[a b]; [1 2] [2 [4 4]]] | table --expand"#,
|
example: r#"[[a b]; [1 2] [2 [4 4]]] | table --expand"#,
|
||||||
result: Some(Value::List {
|
result: Some(Value::List {
|
||||||
vals: vec![
|
vals: vec![
|
||||||
Value::Record {
|
Value::Record {
|
||||||
|
@ -203,7 +203,7 @@ impl Command for Table {
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "Render data in table view (collapsed)",
|
description: "Render data in table view (collapsed)",
|
||||||
example: r#"echo [[a b]; [1 2] [2 [4 4]]] | table --collapse"#,
|
example: r#"[[a b]; [1 2] [2 [4 4]]] | table --collapse"#,
|
||||||
result: Some(Value::List {
|
result: Some(Value::List {
|
||||||
vals: vec![
|
vals: vec![
|
||||||
Value::Record {
|
Value::Record {
|
||||||
|
@ -774,6 +774,7 @@ fn convert_to_table(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[allow(clippy::into_iter_on_ref)]
|
||||||
fn convert_to_table2<'a>(
|
fn convert_to_table2<'a>(
|
||||||
row_offset: usize,
|
row_offset: usize,
|
||||||
input: impl Iterator<Item = &'a Value> + ExactSizeIterator + Clone,
|
input: impl Iterator<Item = &'a Value> + ExactSizeIterator + Clone,
|
||||||
|
|
|
@ -208,7 +208,7 @@ fn errors_fetching_by_index_out_of_bounds() {
|
||||||
fn quoted_column_access() {
|
fn quoted_column_access() {
|
||||||
let actual = nu!(
|
let actual = nu!(
|
||||||
cwd: "tests/fixtures/formats",
|
cwd: "tests/fixtures/formats",
|
||||||
r#"echo '[{"foo bar": {"baz": 4}}]' | from json | get "foo bar".baz.0 "#
|
r#"'[{"foo bar": {"baz": 4}}]' | from json | get "foo bar".baz.0 "#
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(actual.out, "4");
|
assert_eq!(actual.out, "4");
|
||||||
|
|
|
@ -12,7 +12,7 @@ fn writes_out_csv() {
|
||||||
|
|
||||||
nu!(
|
nu!(
|
||||||
cwd: dirs.root(),
|
cwd: dirs.root(),
|
||||||
r#"echo [[name, version, description, license, edition]; [nu, "0.14", "A new type of shell", "MIT", "2018"]] | save save_test_2/cargo_sample.csv"#,
|
r#"[[name, version, description, license, edition]; [nu, "0.14", "A new type of shell", "MIT", "2018"]] | save save_test_2/cargo_sample.csv"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
let actual = file_contents(expected_file);
|
let actual = file_contents(expected_file);
|
||||||
|
@ -30,7 +30,7 @@ fn writes_out_list() {
|
||||||
|
|
||||||
nu!(
|
nu!(
|
||||||
cwd: dirs.root(),
|
cwd: dirs.root(),
|
||||||
r#"echo [a b c d] | save save_test_3/list_sample.txt"#,
|
r#"[a b c d] | save save_test_3/list_sample.txt"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
let actual = file_contents(expected_file);
|
let actual = file_contents(expected_file);
|
||||||
|
@ -48,7 +48,7 @@ fn save_append_will_create_file_if_not_exists() {
|
||||||
|
|
||||||
nu!(
|
nu!(
|
||||||
cwd: dirs.root(),
|
cwd: dirs.root(),
|
||||||
r#"echo hello | save --raw --append save_test_3/new-file.txt"#,
|
r#"'hello' | save --raw --append save_test_3/new-file.txt"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
let actual = file_contents(expected_file);
|
let actual = file_contents(expected_file);
|
||||||
|
@ -74,7 +74,7 @@ fn save_append_will_not_overwrite_content() {
|
||||||
|
|
||||||
nu!(
|
nu!(
|
||||||
cwd: dirs.root(),
|
cwd: dirs.root(),
|
||||||
r#"echo world | save --append save_test_4/new-file.txt"#,
|
r#"'world' | save --append save_test_4/new-file.txt"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
let actual = file_contents(expected_file);
|
let actual = file_contents(expected_file);
|
||||||
|
|
|
@ -16,7 +16,7 @@ fn filters_by_unit_size_comparison() {
|
||||||
fn filters_with_nothing_comparison() {
|
fn filters_with_nothing_comparison() {
|
||||||
let actual = nu!(
|
let actual = nu!(
|
||||||
cwd: "tests/fixtures/formats",
|
cwd: "tests/fixtures/formats",
|
||||||
r#"echo '[{"foo": 3}, {"foo": null}, {"foo": 4}]' | from json | get foo | compact | where $it > 1 | math sum"#
|
r#"'[{"foo": 3}, {"foo": null}, {"foo": 4}]' | from json | get foo | compact | where $it > 1 | math sum"#
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(actual.out, "7");
|
assert_eq!(actual.out, "7");
|
||||||
|
@ -26,7 +26,7 @@ fn filters_with_nothing_comparison() {
|
||||||
fn where_in_table() {
|
fn where_in_table() {
|
||||||
let actual = nu!(
|
let actual = nu!(
|
||||||
cwd: "tests/fixtures/formats",
|
cwd: "tests/fixtures/formats",
|
||||||
r#"echo '[{"name": "foo", "size": 3}, {"name": "foo", "size": 2}, {"name": "bar", "size": 4}]' | from json | where name in ["foo"] | get size | math sum"#
|
r#"'[{"name": "foo", "size": 3}, {"name": "foo", "size": 2}, {"name": "bar", "size": 4}]' | from json | where name in ["foo"] | get size | math sum"#
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(actual.out, "5");
|
assert_eq!(actual.out, "5");
|
||||||
|
@ -36,7 +36,7 @@ fn where_in_table() {
|
||||||
fn where_not_in_table() {
|
fn where_not_in_table() {
|
||||||
let actual = nu!(
|
let actual = nu!(
|
||||||
cwd: "tests/fixtures/formats",
|
cwd: "tests/fixtures/formats",
|
||||||
r#"echo '[{"name": "foo", "size": 3}, {"name": "foo", "size": 2}, {"name": "bar", "size": 4}]' | from json | where name not-in ["foo"] | get size | math sum"#
|
r#"'[{"name": "foo", "size": 3}, {"name": "foo", "size": 2}, {"name": "bar", "size": 4}]' | from json | where name not-in ["foo"] | get size | math sum"#
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(actual.out, "4");
|
assert_eq!(actual.out, "4");
|
||||||
|
|
|
@ -57,7 +57,7 @@ fn test_cd_html_color_flag_dark_false() {
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
actual.out,
|
actual.out,
|
||||||
r"<html><style>body { background-color:white;color:black; }</style><body>Change directory.<br><br>Usage:<br> > cd (path) <br><br>Flags:<br> -h, --help<br> Display this help message<br><br>Parameters:<br> (optional) path <Directory>: the path to change to<br><br>Examples:<br> Change to your home directory<br> > <span style='color:#037979;font-weight:bold;'>cd<span style='color:black;font-weight:normal;'> </span></span><span style='color:#037979;'>~<span style='color:black;font-weight:normal;'><br><br> Change to a directory via abbreviations<br> > </span><span style='color:#037979;font-weight:bold;'>cd<span style='color:black;font-weight:normal;'> </span></span></span><span style='color:#037979;'>d/s/9<span style='color:black;font-weight:normal;'><br><br> Change to the previous working directory ($OLDPWD)<br> > </span><span style='color:#037979;font-weight:bold;'>cd<span style='color:black;font-weight:normal;'> </span></span></span><span style='color:#037979;'>-<span style='color:black;font-weight:normal;'><br><br></body></html></span></span>"
|
r"<html><style>body { background-color:white;color:black; }</style><body>Change directory.<br><br>Usage:<br> > cd (path) <br><br>Flags:<br> -h, --help<br> Display the help message for this command<br><br>Parameters:<br> (optional) path <Directory>: the path to change to<br><br>Examples:<br> Change to your home directory<br> > <span style='color:#037979;font-weight:bold;'>cd<span style='color:black;font-weight:normal;'> </span></span><span style='color:#037979;'>~<span style='color:black;font-weight:normal;'><br><br> Change to a directory via abbreviations<br> > </span><span style='color:#037979;font-weight:bold;'>cd<span style='color:black;font-weight:normal;'> </span></span></span><span style='color:#037979;'>d/s/9<span style='color:black;font-weight:normal;'><br><br> Change to the previous working directory ($OLDPWD)<br> > </span><span style='color:#037979;font-weight:bold;'>cd<span style='color:black;font-weight:normal;'> </span></span></span><span style='color:#037979;'>-<span style='color:black;font-weight:normal;'><br><br></body></html></span></span>"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,6 +72,6 @@ fn test_no_color_flag() {
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
actual.out,
|
actual.out,
|
||||||
r"<html><style>body { background-color:white;color:black; }</style><body>Change directory.<br><br>Usage:<br> > cd (path) <br><br>Flags:<br> -h, --help - Display this help message<br><br>Parameters:<br> (optional) path <Directory>: the path to change to<br><br>Examples:<br> Change to your home directory<br> > cd ~<br><br> Change to a directory via abbreviations<br> > cd d/s/9<br><br> Change to the previous working directory ($OLDPWD)<br> > cd -<br><br></body></html>"
|
r"<html><style>body { background-color:white;color:black; }</style><body>Change directory.<br><br>Usage:<br> > cd (path) <br><br>Flags:<br> -h, --help - Display the help message for this command<br><br>Parameters:<br> (optional) path <Directory>: the path to change to<br><br>Examples:<br> Change to your home directory<br> > cd ~<br><br> Change to a directory via abbreviations<br> > cd d/s/9<br><br> Change to the previous working directory ($OLDPWD)<br> > cd -<br><br></body></html>"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,7 +158,7 @@ impl Signature {
|
||||||
long: "help".into(),
|
long: "help".into(),
|
||||||
short: Some('h'),
|
short: Some('h'),
|
||||||
arg: None,
|
arg: None,
|
||||||
desc: "Display this help message".into(),
|
desc: "Display the help message for this command".into(),
|
||||||
required: false,
|
required: false,
|
||||||
var_id: None,
|
var_id: None,
|
||||||
default_value: None,
|
default_value: None,
|
||||||
|
|
|
@ -61,7 +61,7 @@ module completions {
|
||||||
--no-show-forced-updates # Don't check if a branch is force-updated
|
--no-show-forced-updates # Don't check if a branch is force-updated
|
||||||
-4 # Use IPv4 addresses, ignore IPv6 addresses
|
-4 # Use IPv4 addresses, ignore IPv6 addresses
|
||||||
-6 # Use IPv6 addresses, ignore IPv4 addresses
|
-6 # Use IPv6 addresses, ignore IPv4 addresses
|
||||||
--help # Display this help message
|
--help # Display the help message for this command
|
||||||
]
|
]
|
||||||
|
|
||||||
# Check out git branches and files
|
# Check out git branches and files
|
||||||
|
@ -88,7 +88,7 @@ module completions {
|
||||||
-b: string # create and checkout a new branch
|
-b: string # create and checkout a new branch
|
||||||
-B: string # create/reset and checkout a branch
|
-B: string # create/reset and checkout a branch
|
||||||
-l # create reflog for new branch
|
-l # create reflog for new branch
|
||||||
--help # Display this help message
|
--help # Display the help message for this command
|
||||||
]
|
]
|
||||||
|
|
||||||
# Push changes
|
# Push changes
|
||||||
|
@ -120,7 +120,7 @@ module completions {
|
||||||
--tags # push tags (can't be used with --all or --mirror)
|
--tags # push tags (can't be used with --all or --mirror)
|
||||||
--thin # use thin pack
|
--thin # use thin pack
|
||||||
--verbose(-v) # be more verbose
|
--verbose(-v) # be more verbose
|
||||||
--help # Display this help message
|
--help # Display the help message for this command
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ let light_theme = {
|
||||||
|
|
||||||
# The default config record. This is where much of your global configuration is setup.
|
# The default config record. This is where much of your global configuration is setup.
|
||||||
let-env config = {
|
let-env config = {
|
||||||
external_completer: $nothing # check 'carapace_completer' above to as example
|
external_completer: null # check 'carapace_completer' above to as example
|
||||||
filesize_metric: false # true => (KB, MB, GB), false => (KiB, MiB, GiB)
|
filesize_metric: false # true => (KB, MB, GB), false => (KiB, MiB, GiB)
|
||||||
table_mode: rounded # basic, compact, compact_double, light, thin, with_love, rounded, reinforced, heavy, none, other
|
table_mode: rounded # basic, compact, compact_double, light, thin, with_love, rounded, reinforced, heavy, none, other
|
||||||
use_ls_colors: true
|
use_ls_colors: true
|
||||||
|
|
|
@ -77,7 +77,7 @@ def signatures():
|
||||||
"short": "h",
|
"short": "h",
|
||||||
"arg": None,
|
"arg": None,
|
||||||
"required": False,
|
"required": False,
|
||||||
"desc": "Display this help message",
|
"desc": "Display the help message for this command",
|
||||||
"var_id": None
|
"var_id": None
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -121,7 +121,10 @@ fn allow_missing_optional_params() -> TestResult {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn help_present_in_def() -> TestResult {
|
fn help_present_in_def() -> TestResult {
|
||||||
run_test_contains("def foo [] {}; help foo;", "Display this help message")
|
run_test_contains(
|
||||||
|
"def foo [] {}; help foo;",
|
||||||
|
"Display the help message for this command",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -53,7 +53,7 @@ fn in_and_if_else() -> TestResult {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn help_works_with_missing_requirements() -> TestResult {
|
fn help_works_with_missing_requirements() -> TestResult {
|
||||||
run_test(r#"each --help | lines | length"#, "29")
|
run_test(r#"each --help | lines | length"#, "37")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -251,7 +251,7 @@ fn length_for_rows() -> TestResult {
|
||||||
#[test]
|
#[test]
|
||||||
fn length_defaulted_columns() -> TestResult {
|
fn length_defaulted_columns() -> TestResult {
|
||||||
run_test(
|
run_test(
|
||||||
r#"echo [[name, age]; [test, 10]] | default 11 age | get 0 | columns | length"#,
|
r#"[[name, age]; [test, 10]] | default 11 age | get 0 | columns | length"#,
|
||||||
"2",
|
"2",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -662,7 +662,7 @@ fn argument_subexpression_reports_errors() {
|
||||||
fn can_process_one_row_from_internal_and_pipes_it_to_stdin_of_external() {
|
fn can_process_one_row_from_internal_and_pipes_it_to_stdin_of_external() {
|
||||||
let actual = nu!(
|
let actual = nu!(
|
||||||
cwd: ".",
|
cwd: ".",
|
||||||
r#"echo "nushelll" | nu --testbin chop"#
|
r#""nushelll" | nu --testbin chop"#
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(actual.out, "nushell");
|
assert_eq!(actual.out, "nushell");
|
||||||
|
@ -1232,7 +1232,7 @@ mod parse {
|
||||||
> debug {flags}
|
> debug {flags}
|
||||||
|
|
||||||
flags:
|
flags:
|
||||||
-h, --help: Display this help message
|
-h, --help: Display the help message for this command
|
||||||
-r, --raw: Prints the raw value representation.
|
-r, --raw: Prints the raw value representation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue