Move capitalize, downcase, upcase to /cases; fix some example descriptions; clarify usage text (#5572)

Co-authored-by: kyle <kyle@archtop.local>
This commit is contained in:
krober 2022-05-17 23:55:43 -05:00 committed by GitHub
parent 7a78171b34
commit 3e09158afc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 16 additions and 16 deletions

View file

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

View file

@ -1,16 +1,22 @@
pub mod camel_case;
pub mod capitalize;
pub mod downcase;
pub mod kebab_case;
pub mod pascal_case;
pub mod screaming_snake_case;
pub mod snake_case;
pub mod str_;
pub mod upcase;
pub use camel_case::SubCommand as StrCamelCase;
pub use capitalize::SubCommand as StrCapitalize;
pub use downcase::SubCommand as StrDowncase;
pub use kebab_case::SubCommand as StrKebabCase;
pub use pascal_case::SubCommand as StrPascalCase;
pub use screaming_snake_case::SubCommand as StrScreamingSnakeCase;
pub use snake_case::SubCommand as StrSnakeCase;
pub use str_::Str;
pub use upcase::SubCommand as StrUpcase;
use nu_engine::CallExt;

View file

@ -41,7 +41,7 @@ impl Command for SubCommand {
fn examples(&self) -> Vec<Example> {
vec![
Example {
description: "convert a string to camelCase",
description: "convert a string to SCREAMING_SNAKE_CASE",
example: r#" "NuShell" | str screaming-snake-case"#,
result: Some(Value::String {
val: "NU_SHELL".to_string(),
@ -49,7 +49,7 @@ impl Command for SubCommand {
}),
},
Example {
description: "convert a string to camelCase",
description: "convert a string to SCREAMING_SNAKE_CASE",
example: r#" "this_is_the_second_case" | str screaming-snake-case"#,
result: Some(Value::String {
val: "THIS_IS_THE_SECOND_CASE".to_string(),
@ -57,7 +57,7 @@ impl Command for SubCommand {
}),
},
Example {
description: "convert a string to camelCase",
description: "convert a string to SCREAMING_SNAKE_CASE",
example: r#""this-is-the-first-case" | str screaming-snake-case"#,
result: Some(Value::String {
val: "THIS_IS_THE_FIRST_CASE".to_string(),

View file

@ -40,7 +40,7 @@ impl Command for SubCommand {
fn examples(&self) -> Vec<Example> {
vec![
Example {
description: "convert a string to camelCase",
description: "convert a string to snake_case",
example: r#" "NuShell" | str snake-case"#,
result: Some(Value::String {
val: "nu_shell".to_string(),
@ -48,7 +48,7 @@ impl Command for SubCommand {
}),
},
Example {
description: "convert a string to camelCase",
description: "convert a string to snake_case",
example: r#" "this_is_the_second_case" | str snake-case"#,
result: Some(Value::String {
val: "this_is_the_second_case".to_string(),
@ -56,7 +56,7 @@ impl Command for SubCommand {
}),
},
Example {
description: "convert a string to camelCase",
description: "convert a string to snake_case",
example: r#""this-is-the-first-case" | str snake-case"#,
result: Some(Value::String {
val: "this_is_the_first_case".to_string(),
@ -64,7 +64,7 @@ impl Command for SubCommand {
}),
},
Example {
description: "convert a column from a table to snake-case",
description: "convert a column from a table to snake_case",
example: r#"[[lang, gems]; [nuTest, 100]] | str snake-case lang"#,
result: Some(Value::List {
vals: vec![Value::Record {

View file

@ -18,7 +18,7 @@ impl Command for Str {
}
fn usage(&self) -> &str {
"Various commands for working with string data."
"Various commands for working with string data"
}
fn run(

View file

@ -48,7 +48,7 @@ impl Command for SubCommand {
}
fn usage(&self) -> &str {
"Returns starting index of given pattern in string counting from 0. Returns -1 when there are no results."
"Returns start index of first occurrence of pattern in string, or -1 if no match"
}
fn run(

View file

@ -1,8 +1,6 @@
mod capitalize;
mod case;
mod collect;
mod contains;
mod downcase;
mod ends_with;
mod index_of;
mod length;
@ -13,13 +11,10 @@ mod rpad;
mod starts_with;
mod substring;
mod trim;
mod upcase;
pub use capitalize::SubCommand as StrCapitalize;
pub use case::*;
pub use collect::*;
pub use contains::SubCommand as StrContains;
pub use downcase::SubCommand as StrDowncase;
pub use ends_with::SubCommand as StrEndswith;
pub use index_of::SubCommand as StrIndexOf;
pub use length::SubCommand as StrLength;
@ -30,4 +25,3 @@ pub use rpad::SubCommand as StrRpad;
pub use starts_with::SubCommand as StrStartsWith;
pub use substring::SubCommand as StrSubstring;
pub use trim::Trim as StrTrim;
pub use upcase::SubCommand as StrUpcase;