Fix command descriptions+examples (#5129)

* Fix exit usage

* Move dfr as-date* format examples to extra_usage

* Update command usage and examples

* More docs on `str trim`

Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
This commit is contained in:
Reilly Wood
2022-04-08 01:30:49 -07:00
committed by GitHub
parent 6b4cb8b0e0
commit d38a3a8b4e
39 changed files with 104 additions and 62 deletions

View File

@ -32,7 +32,7 @@ impl Command for DetectColumns {
}
fn usage(&self) -> &str {
"splits contents across multiple columns via the separator."
"Attempt to automatically split text into multiple columns"
}
fn run(

View File

@ -17,7 +17,7 @@ impl Command for SubCommand {
}
fn usage(&self) -> &str {
"splits a string's characters into separate rows"
"Split a string's characters into separate rows"
}
fn examples(&self) -> Vec<Example> {

View File

@ -18,7 +18,7 @@ impl Command for SubCommand {
.required(
"separator",
SyntaxShape::String,
"the character that denotes what separates columns",
"the character or string that denotes what separates columns",
)
.switch("collapse-empty", "remove empty columns", Some('c'))
.rest(
@ -30,7 +30,7 @@ impl Command for SubCommand {
}
fn usage(&self) -> &str {
"splits contents across multiple columns via the separator."
"Split a string into multiple columns using a separator"
}
fn run(

View File

@ -24,7 +24,7 @@ impl Command for SubCommand {
}
fn usage(&self) -> &str {
"splits contents over multiple rows via the separator."
"Split a string into multiple rows using a separator"
}
fn run(

View File

@ -24,7 +24,7 @@ impl Command for SubCommand {
}
fn usage(&self) -> &str {
"capitalizes text"
"Capitalize text"
}
fn run(

View File

@ -26,7 +26,7 @@ impl Command for SubCommand {
}
fn usage(&self) -> &str {
"converts a string to camelCase"
"Convert a string to camelCase"
}
fn run(

View File

@ -26,7 +26,7 @@ impl Command for SubCommand {
}
fn usage(&self) -> &str {
"converts a string to kebab-case"
"Convert a string to kebab-case"
}
fn run(

View File

@ -26,7 +26,7 @@ impl Command for SubCommand {
}
fn usage(&self) -> &str {
"converts a string to PascalCase"
"Convert a string to PascalCase"
}
fn run(

View File

@ -25,7 +25,7 @@ impl Command for SubCommand {
}
fn usage(&self) -> &str {
"converts a string to SCREAMING_SNAKE_CASE"
"Convert a string to SCREAMING_SNAKE_CASE"
}
fn run(

View File

@ -24,7 +24,7 @@ impl Command for SubCommand {
.category(Category::Strings)
}
fn usage(&self) -> &str {
"converts a string to snake_case"
"Convert a string to snake_case"
}
fn run(

View File

@ -25,7 +25,11 @@ impl Command for StrCollect {
}
fn usage(&self) -> &str {
"creates a string from the input, optionally using a separator"
"Concatenate multiple strings into a single string, with an optional separator between each"
}
fn search_terms(&self) -> Vec<&str> {
vec!["join", "concatenate"]
}
fn run(

View File

@ -24,7 +24,7 @@ impl Command for SubCommand {
}
fn usage(&self) -> &str {
"downcases text"
"Make text lowercase"
}
fn search_terms(&self) -> Vec<&str> {

View File

@ -26,7 +26,7 @@ impl Command for SubCommand {
}
fn usage(&self) -> &str {
"checks if string ends with pattern"
"Check if a string ends with a pattern"
}
fn run(

View File

@ -24,7 +24,7 @@ impl Command for SubCommand {
}
fn usage(&self) -> &str {
"outputs the lengths of the strings in the pipeline"
"Output the length of any strings in the pipeline"
}
fn run(

View File

@ -38,7 +38,7 @@ impl Command for SubCommand {
}
fn usage(&self) -> &str {
"pad a string with a character a certain length"
"Left-pad a string to a specific length"
}
fn run(
@ -54,7 +54,7 @@ impl Command for SubCommand {
fn examples(&self) -> Vec<Example> {
vec![
Example {
description: "Left pad a string with a character a number of places",
description: "Left-pad a string with asterisks until it's 10 characters wide",
example: "'nushell' | str lpad -l 10 -c '*'",
result: Some(Value::String {
val: "***nushell".to_string(),
@ -62,7 +62,7 @@ impl Command for SubCommand {
}),
},
Example {
description: "Left pad a string with a character a number of places",
description: "Left-pad a string with zeroes until it's 10 character wide",
example: "'123' | str lpad -l 10 -c '0'",
result: Some(Value::String {
val: "0000000123".to_string(),

View File

@ -42,7 +42,7 @@ impl Command for SubCommand {
}
fn usage(&self) -> &str {
"finds and replaces text"
"Find and replace text"
}
fn run(

View File

@ -24,7 +24,7 @@ impl Command for SubCommand {
}
fn usage(&self) -> &str {
"outputs the reversals of the strings in the pipeline"
"Reverse every string in the pipeline"
}
fn run(
@ -38,14 +38,37 @@ impl Command for SubCommand {
}
fn examples(&self) -> Vec<Example> {
vec![Example {
description: "Return the reversals of multiple strings",
example: "'Nushell' | str reverse",
result: Some(Value::String {
val: "llehsuN".to_string(),
span: Span::test_data(),
}),
}]
vec![
Example {
description: "Reverse a single string",
example: "'Nushell' | str reverse",
result: Some(Value::String {
val: "llehsuN".to_string(),
span: Span::test_data(),
}),
},
Example {
description: "Reverse multiple strings in a list",
example: "['Nushell' 'is' 'cool'] | str reverse",
result: Some(Value::List {
vals: vec![
Value::String {
val: "llehsuN".to_string(),
span: Span::test_data(),
},
Value::String {
val: "si".to_string(),
span: Span::test_data(),
},
Value::String {
val: "looc".to_string(),
span: Span::test_data(),
},
],
span: Span::test_data(),
}),
},
]
}
}

View File

@ -38,7 +38,7 @@ impl Command for SubCommand {
}
fn usage(&self) -> &str {
"pad a string with a character a certain length"
"Right-pad a string to a specific length"
}
fn run(
@ -54,7 +54,7 @@ impl Command for SubCommand {
fn examples(&self) -> Vec<Example> {
vec![
Example {
description: "Right pad a string with a character a number of places",
description: "Right-pad a string with asterisks until it's 10 characters wide",
example: "'nushell' | str rpad -l 10 -c '*'",
result: Some(Value::String {
val: "nushell***".to_string(),
@ -62,7 +62,7 @@ impl Command for SubCommand {
}),
},
Example {
description: "Right pad a string with a character a number of places",
description: "Right-pad a string with zeroes until it's 10 characters wide",
example: "'123' | str rpad -l 10 -c '0'",
result: Some(Value::String {
val: "1230000000".to_string(),

View File

@ -33,7 +33,7 @@ impl Command for SubCommand {
}
fn usage(&self) -> &str {
"checks if string starts with pattern"
"Check if string starts with a pattern"
}
fn run(

View File

@ -45,7 +45,7 @@ impl Command for SubCommand {
}
fn usage(&self) -> &str {
"substrings text"
"Get part of a string"
}
fn run(

View File

@ -59,7 +59,11 @@ impl Command for SubCommand {
.switch("format", "trims spaces replacing multiple characters with singles in the middle (default: whitespace)", Some('f'))
}
fn usage(&self) -> &str {
"trims text"
"Trim whitespace or specific character"
}
fn search_terms(&self) -> Vec<&str> {
vec!["whitespace", "strip", "lstrip", "rstrip"]
}
fn run(

View File

@ -21,7 +21,7 @@ impl Command for SubCommand {
}
fn usage(&self) -> &str {
"upcases text"
"Make text uppercase"
}
fn search_terms(&self) -> Vec<&str> {