mirror of
https://github.com/nushell/nushell
synced 2024-11-10 15:14:14 +00:00
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:
parent
9e39284de9
commit
51c685aa99
6 changed files with 10 additions and 10 deletions
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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>(
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue