Add str collect (#311)

* Add str collect

* Oops, missing file
This commit is contained in:
JT
2021-11-09 14:59:44 +13:00
committed by GitHub
parent ce714f098f
commit 47628946b6
6 changed files with 117 additions and 18 deletions

View File

@ -6,9 +6,9 @@ use nu_protocol::{
};
#[derive(Clone)]
pub struct Case;
pub struct Str;
impl Command for Case {
impl Command for Str {
fn name(&self) -> &str {
"str"
}
@ -18,7 +18,7 @@ impl Command for Case {
}
fn usage(&self) -> &str {
"Converts strings into different kind of cases: camel, kebab, pascal, snake, and screaming snake."
"Various commands for working with string data."
}
fn run(
@ -29,7 +29,7 @@ impl Command for Case {
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
Ok(Value::String {
val: get_full_help(&Case.signature(), &Case.examples(), engine_state),
val: get_full_help(&Str.signature(), &Str.examples(), engine_state),
span: call.head,
}
.into_pipeline_data())
@ -44,6 +44,6 @@ mod test {
fn test_examples() {
use crate::test_examples;
test_examples(Case {})
test_examples(Str {})
}
}

View File

@ -5,12 +5,12 @@ pub mod pascal_case;
pub mod screaming_snake_case;
pub mod snake_case;
pub use camel_case::SubCommand as CamelCase;
pub use command::Case;
pub use kebab_case::SubCommand as KebabCase;
pub use pascal_case::SubCommand as PascalCase;
pub use screaming_snake_case::SubCommand as ScreamingSnakeCase;
pub use snake_case::SubCommand as SnakeCase;
pub use camel_case::SubCommand as StrCamelCase;
pub use command::Str;
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;
use nu_engine::CallExt;