From 57073cc6cf51f69c85086e3e1dec34853e7b4b3d Mon Sep 17 00:00:00 2001 From: Sam Bordo <47604563+sambordo1@users.noreply.github.com> Date: Fri, 23 Jul 2021 03:13:11 -0400 Subject: [PATCH] port capitalize to engine-p (#3794) Part of #3390. --- .../src/commands/strings/str_/capitalize.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/crates/nu-command/src/commands/strings/str_/capitalize.rs b/crates/nu-command/src/commands/strings/str_/capitalize.rs index f4d81ef86..b0f6ff53f 100644 --- a/crates/nu-command/src/commands/strings/str_/capitalize.rs +++ b/crates/nu-command/src/commands/strings/str_/capitalize.rs @@ -2,9 +2,7 @@ use crate::prelude::*; use nu_engine::WholeStreamCommand; use nu_errors::ShellError; use nu_protocol::ShellTypeName; -use nu_protocol::{ - ColumnPath, Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value, -}; +use nu_protocol::{ColumnPath, Primitive, Signature, SyntaxShape, UntaggedValue, Value}; use nu_source::Tag; use nu_value_ext::ValueExt; @@ -30,7 +28,7 @@ impl WholeStreamCommand for SubCommand { "capitalizes text" } - fn run_with_actions(&self, args: CommandArgs) -> Result { + fn run(&self, args: CommandArgs) -> Result { operate(args) } @@ -43,7 +41,7 @@ impl WholeStreamCommand for SubCommand { } } -fn operate(args: CommandArgs) -> Result { +fn operate(args: CommandArgs) -> Result { let (options, input) = ( Arguments { column_paths: args.rest(0)?, @@ -54,7 +52,7 @@ fn operate(args: CommandArgs) -> Result { Ok(input .map(move |v| { if options.column_paths.is_empty() { - ReturnSuccess::value(action(&v, v.tag())?) + action(&v, v.tag()) } else { let mut ret = v; @@ -65,10 +63,10 @@ fn operate(args: CommandArgs) -> Result { )?; } - ReturnSuccess::value(ret) + Ok(ret) } }) - .into_action_stream()) + .into_input_stream()) } fn action(input: &Value, tag: impl Into) -> Result {