port string case commands to engine-p (#3649)

Port snake_case and friends to engine-p syntax.

Part of #3390.
This commit is contained in:
Eli Flanagan 2021-06-18 23:01:18 -04:00 committed by GitHub
parent 9e39284de9
commit 51c685aa99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 10 deletions

View file

@ -23,7 +23,7 @@ impl WholeStreamCommand for SubCommand {
"converts a string to camelCase"
}
fn run_with_actions(&self, args: CommandArgs) -> Result<ActionStream, ShellError> {
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
operate(args, &to_camel_case)
}

View file

@ -23,7 +23,7 @@ impl WholeStreamCommand for SubCommand {
"converts a string to kebab-case"
}
fn run_with_actions(&self, args: CommandArgs) -> Result<ActionStream, ShellError> {
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
operate(args, &to_kebab_case)
}

View file

@ -7,7 +7,7 @@ pub mod snake_case;
use crate::prelude::*;
use nu_errors::ShellError;
use nu_protocol::ShellTypeName;
use nu_protocol::{ColumnPath, Primitive, ReturnSuccess, UntaggedValue, Value};
use nu_protocol::{ColumnPath, Primitive, UntaggedValue, Value};
use nu_source::Tag;
use nu_value_ext::ValueExt;
@ -20,7 +20,7 @@ struct Arguments {
column_paths: Vec<ColumnPath>,
}
pub fn operate<F>(args: CommandArgs, case_operation: &'static F) -> Result<ActionStream, ShellError>
pub fn operate<F>(args: CommandArgs, case_operation: &'static F) -> Result<OutputStream, ShellError>
where
F: Fn(&str) -> String + Send + Sync + 'static,
{
@ -34,7 +34,7 @@ where
Ok(input
.map(move |v| {
if options.column_paths.is_empty() {
ReturnSuccess::value(action(&v, v.tag(), &case_operation)?)
action(&v, v.tag(), &case_operation)
} else {
let mut ret = v;
@ -45,10 +45,10 @@ where
)?;
}
ReturnSuccess::value(ret)
Ok(ret)
}
})
.into_action_stream())
.into_input_stream())
}
pub fn action<F>(

View file

@ -23,7 +23,7 @@ impl WholeStreamCommand for SubCommand {
"converts a string to PascalCase"
}
fn run_with_actions(&self, args: CommandArgs) -> Result<ActionStream, ShellError> {
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
operate(args, &to_pascal_case)
}

View file

@ -23,7 +23,7 @@ impl WholeStreamCommand for SubCommand {
"converts a string to SCREAMING_SNAKE_CASE"
}
fn run_with_actions(&self, args: CommandArgs) -> Result<ActionStream, ShellError> {
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
operate(args, &to_screaming_snake_case)
}

View file

@ -23,7 +23,7 @@ impl WholeStreamCommand for SubCommand {
"converts a string to snake_case"
}
fn run_with_actions(&self, args: CommandArgs) -> Result<ActionStream, ShellError> {
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
operate(args, &to_snake_case)
}