From e4214dded50ed9dd1477d29dd64f49599bf86f43 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Mon, 12 Apr 2021 10:09:26 +1200 Subject: [PATCH 1/5] Split OutputStream into ActionStream/OutputStream --- crates/nu-cli/src/lib.rs | 2 +- crates/nu-cli/src/prelude.rs | 14 ++-- crates/nu-command/src/commands/all.rs | 7 +- .../nu-command/src/commands/ansi/command.rs | 8 +- crates/nu-command/src/commands/ansi/strip.rs | 6 +- crates/nu-command/src/commands/any.rs | 6 +- crates/nu-command/src/commands/append.rs | 4 +- crates/nu-command/src/commands/autoenv.rs | 4 +- .../nu-command/src/commands/autoenv_trust.rs | 4 +- .../src/commands/autoenv_untrust.rs | 4 +- .../src/commands/autoview/command.rs | 6 +- crates/nu-command/src/commands/benchmark.rs | 10 +-- .../nu-command/src/commands/build_string.rs | 4 +- crates/nu-command/src/commands/cal.rs | 6 +- crates/nu-command/src/commands/cd.rs | 2 +- crates/nu-command/src/commands/char_.rs | 8 +- crates/nu-command/src/commands/chart.rs | 4 +- crates/nu-command/src/commands/clear.rs | 4 +- crates/nu-command/src/commands/clip.rs | 8 +- crates/nu-command/src/commands/compact.rs | 6 +- .../nu-command/src/commands/config/clear.rs | 8 +- .../nu-command/src/commands/config/command.rs | 8 +- crates/nu-command/src/commands/config/get.rs | 10 +-- crates/nu-command/src/commands/config/path.rs | 8 +- .../nu-command/src/commands/config/remove.rs | 8 +- crates/nu-command/src/commands/config/set.rs | 10 +-- .../src/commands/config/set_into.rs | 8 +- crates/nu-command/src/commands/cp.rs | 2 +- .../nu-command/src/commands/date/command.rs | 4 +- crates/nu-command/src/commands/date/format.rs | 6 +- .../src/commands/date/list_timezone.rs | 6 +- crates/nu-command/src/commands/date/now.rs | 6 +- .../nu-command/src/commands/date/to_table.rs | 6 +- .../src/commands/date/to_timezone.rs | 6 +- crates/nu-command/src/commands/date/utc.rs | 2 +- crates/nu-command/src/commands/debug.rs | 6 +- crates/nu-command/src/commands/def.rs | 4 +- crates/nu-command/src/commands/default.rs | 6 +- crates/nu-command/src/commands/describe.rs | 6 +- crates/nu-command/src/commands/do_.rs | 10 +-- crates/nu-command/src/commands/drop/column.rs | 6 +- .../nu-command/src/commands/drop/command.rs | 8 +- crates/nu-command/src/commands/du.rs | 6 +- .../nu-command/src/commands/each/command.rs | 6 +- crates/nu-command/src/commands/each/group.rs | 25 ++----- crates/nu-command/src/commands/each/window.rs | 4 +- crates/nu-command/src/commands/echo.rs | 72 ++++++++++-------- crates/nu-command/src/commands/empty.rs | 20 ++--- crates/nu-command/src/commands/enter.rs | 18 ++--- crates/nu-command/src/commands/every.rs | 6 +- crates/nu-command/src/commands/exec.rs | 4 +- crates/nu-command/src/commands/exit.rs | 6 +- crates/nu-command/src/commands/first.rs | 6 +- crates/nu-command/src/commands/flatten.rs | 6 +- .../nu-command/src/commands/format/command.rs | 6 +- .../src/commands/format/format_filesize.rs | 14 ++-- crates/nu-command/src/commands/from.rs | 4 +- crates/nu-command/src/commands/from_csv.rs | 4 +- .../src/commands/from_delimited_data.rs | 6 +- crates/nu-command/src/commands/from_eml.rs | 6 +- crates/nu-command/src/commands/from_ics.rs | 6 +- crates/nu-command/src/commands/from_ini.rs | 8 +- crates/nu-command/src/commands/from_json.rs | 12 +-- crates/nu-command/src/commands/from_ods.rs | 6 +- crates/nu-command/src/commands/from_ssv.rs | 8 +- crates/nu-command/src/commands/from_toml.rs | 8 +- crates/nu-command/src/commands/from_tsv.rs | 4 +- crates/nu-command/src/commands/from_url.rs | 6 +- crates/nu-command/src/commands/from_vcf.rs | 6 +- crates/nu-command/src/commands/from_xlsx.rs | 6 +- crates/nu-command/src/commands/from_xml.rs | 8 +- crates/nu-command/src/commands/from_yaml.rs | 10 +-- crates/nu-command/src/commands/get.rs | 8 +- crates/nu-command/src/commands/group_by.rs | 20 +++-- .../nu-command/src/commands/group_by_date.rs | 6 +- .../nu-command/src/commands/hash_/base64_.rs | 8 +- .../nu-command/src/commands/hash_/command.rs | 4 +- crates/nu-command/src/commands/hash_/md5_.rs | 6 +- crates/nu-command/src/commands/headers.rs | 6 +- crates/nu-command/src/commands/help.rs | 16 ++-- crates/nu-command/src/commands/histogram.rs | 6 +- crates/nu-command/src/commands/history.rs | 8 +- crates/nu-command/src/commands/if_.rs | 11 ++- crates/nu-command/src/commands/insert.rs | 26 +++---- .../nu-command/src/commands/into/command.rs | 4 +- crates/nu-command/src/commands/into/int.rs | 6 +- .../nu-command/src/commands/keep/command.rs | 6 +- crates/nu-command/src/commands/keep/until.rs | 4 +- crates/nu-command/src/commands/keep/while_.rs | 4 +- crates/nu-command/src/commands/kill.rs | 6 +- crates/nu-command/src/commands/last.rs | 6 +- crates/nu-command/src/commands/length.rs | 4 +- crates/nu-command/src/commands/let_.rs | 6 +- crates/nu-command/src/commands/let_env.rs | 6 +- crates/nu-command/src/commands/lines.rs | 6 +- crates/nu-command/src/commands/ls.rs | 2 +- crates/nu-command/src/commands/macros.rs | 2 +- crates/nu-command/src/commands/math/abs.rs | 4 +- crates/nu-command/src/commands/math/avg.rs | 2 +- crates/nu-command/src/commands/math/ceil.rs | 2 +- .../nu-command/src/commands/math/command.rs | 4 +- crates/nu-command/src/commands/math/eval.rs | 8 +- crates/nu-command/src/commands/math/floor.rs | 2 +- crates/nu-command/src/commands/math/max.rs | 2 +- crates/nu-command/src/commands/math/median.rs | 2 +- crates/nu-command/src/commands/math/min.rs | 2 +- crates/nu-command/src/commands/math/mode.rs | 2 +- .../nu-command/src/commands/math/product.rs | 2 +- crates/nu-command/src/commands/math/round.rs | 6 +- crates/nu-command/src/commands/math/sqrt.rs | 6 +- crates/nu-command/src/commands/math/stddev.rs | 6 +- crates/nu-command/src/commands/math/sum.rs | 2 +- crates/nu-command/src/commands/math/utils.rs | 10 +-- .../nu-command/src/commands/math/variance.rs | 6 +- crates/nu-command/src/commands/merge.rs | 6 +- crates/nu-command/src/commands/mkdir.rs | 4 +- .../nu-command/src/commands/move_/command.rs | 8 +- crates/nu-command/src/commands/move_/mv.rs | 4 +- crates/nu-command/src/commands/next.rs | 4 +- crates/nu-command/src/commands/nth.rs | 6 +- crates/nu-command/src/commands/nu/plugin.rs | 4 +- crates/nu-command/src/commands/open.rs | 10 +-- .../nu-command/src/commands/parse/command.rs | 6 +- .../nu-command/src/commands/path/basename.rs | 2 +- .../nu-command/src/commands/path/command.rs | 4 +- .../nu-command/src/commands/path/dirname.rs | 2 +- crates/nu-command/src/commands/path/exists.rs | 2 +- crates/nu-command/src/commands/path/expand.rs | 2 +- .../nu-command/src/commands/path/extension.rs | 2 +- .../nu-command/src/commands/path/filestem.rs | 2 +- crates/nu-command/src/commands/path/join.rs | 2 +- crates/nu-command/src/commands/path/mod.rs | 4 +- crates/nu-command/src/commands/path/type.rs | 2 +- crates/nu-command/src/commands/pivot.rs | 6 +- crates/nu-command/src/commands/prepend.rs | 6 +- crates/nu-command/src/commands/prev.rs | 4 +- crates/nu-command/src/commands/pwd.rs | 4 +- crates/nu-command/src/commands/random/bool.rs | 6 +- .../nu-command/src/commands/random/chars.rs | 6 +- .../nu-command/src/commands/random/command.rs | 4 +- .../nu-command/src/commands/random/decimal.rs | 8 +- crates/nu-command/src/commands/random/dice.rs | 6 +- .../nu-command/src/commands/random/integer.rs | 8 +- crates/nu-command/src/commands/random/uuid.rs | 6 +- crates/nu-command/src/commands/range.rs | 6 +- crates/nu-command/src/commands/reduce.rs | 10 +-- crates/nu-command/src/commands/reject.rs | 6 +- crates/nu-command/src/commands/rename.rs | 6 +- crates/nu-command/src/commands/reverse.rs | 6 +- crates/nu-command/src/commands/rm.rs | 6 +- crates/nu-command/src/commands/roll/column.rs | 6 +- .../nu-command/src/commands/roll/command.rs | 6 +- crates/nu-command/src/commands/roll/up.rs | 6 +- .../nu-command/src/commands/rotate/command.rs | 8 +- .../src/commands/rotate/counter_clockwise.rs | 8 +- .../nu-command/src/commands/run_external.rs | 6 +- crates/nu-command/src/commands/save.rs | 6 +- crates/nu-command/src/commands/select.rs | 6 +- crates/nu-command/src/commands/seq.rs | 4 +- crates/nu-command/src/commands/seq_dates.rs | 8 +- crates/nu-command/src/commands/shells.rs | 4 +- crates/nu-command/src/commands/shuffle.rs | 6 +- crates/nu-command/src/commands/size.rs | 6 +- .../nu-command/src/commands/skip/command.rs | 6 +- crates/nu-command/src/commands/skip/until.rs | 4 +- crates/nu-command/src/commands/skip/while_.rs | 4 +- crates/nu-command/src/commands/sleep.rs | 4 +- crates/nu-command/src/commands/sort_by.rs | 6 +- crates/nu-command/src/commands/source.rs | 8 +- crates/nu-command/src/commands/split/chars.rs | 10 +-- .../nu-command/src/commands/split/column.rs | 6 +- .../nu-command/src/commands/split/command.rs | 4 +- crates/nu-command/src/commands/split/row.rs | 10 +-- crates/nu-command/src/commands/split_by.rs | 6 +- .../src/commands/str_/capitalize.rs | 6 +- .../src/commands/str_/case/camel_case.rs | 2 +- .../src/commands/str_/case/kebab_case.rs | 2 +- .../nu-command/src/commands/str_/case/mod.rs | 4 +- .../src/commands/str_/case/pascal_case.rs | 2 +- .../str_/case/screaming_snake_case.rs | 2 +- .../src/commands/str_/case/snake_case.rs | 2 +- .../nu-command/src/commands/str_/collect.rs | 6 +- .../nu-command/src/commands/str_/command.rs | 4 +- .../nu-command/src/commands/str_/contains.rs | 6 +- .../nu-command/src/commands/str_/downcase.rs | 6 +- .../nu-command/src/commands/str_/ends_with.rs | 6 +- .../src/commands/str_/find_replace.rs | 6 +- crates/nu-command/src/commands/str_/from.rs | 6 +- .../nu-command/src/commands/str_/index_of.rs | 6 +- crates/nu-command/src/commands/str_/length.rs | 6 +- crates/nu-command/src/commands/str_/lpad.rs | 6 +- .../nu-command/src/commands/str_/reverse.rs | 6 +- crates/nu-command/src/commands/str_/rpad.rs | 6 +- .../src/commands/str_/starts_with.rs | 6 +- .../nu-command/src/commands/str_/substring.rs | 6 +- .../src/commands/str_/to_datetime.rs | 6 +- .../src/commands/str_/to_decimal.rs | 6 +- .../src/commands/str_/to_integer.rs | 6 +- .../nu-command/src/commands/str_/trim/mod.rs | 4 +- .../src/commands/str_/trim/trim_both_ends.rs | 2 +- .../src/commands/str_/trim/trim_left.rs | 2 +- .../src/commands/str_/trim/trim_right.rs | 2 +- crates/nu-command/src/commands/str_/upcase.rs | 6 +- crates/nu-command/src/commands/tags.rs | 6 +- crates/nu-command/src/commands/termsize.rs | 10 +-- crates/nu-command/src/commands/to.rs | 4 +- crates/nu-command/src/commands/to_csv.rs | 4 +- .../src/commands/to_delimited_data.rs | 4 +- crates/nu-command/src/commands/to_html.rs | 8 +- crates/nu-command/src/commands/to_json.rs | 6 +- crates/nu-command/src/commands/to_md.rs | 6 +- crates/nu-command/src/commands/to_toml.rs | 6 +- crates/nu-command/src/commands/to_tsv.rs | 4 +- crates/nu-command/src/commands/to_url.rs | 6 +- crates/nu-command/src/commands/to_xml.rs | 6 +- crates/nu-command/src/commands/to_yaml.rs | 6 +- crates/nu-command/src/commands/touch.rs | 6 +- crates/nu-command/src/commands/uniq.rs | 6 +- crates/nu-command/src/commands/update.rs | 26 +++---- .../nu-command/src/commands/url_/command.rs | 4 +- crates/nu-command/src/commands/url_/host.rs | 2 +- crates/nu-command/src/commands/url_/mod.rs | 4 +- crates/nu-command/src/commands/url_/path.rs | 2 +- crates/nu-command/src/commands/url_/query.rs | 2 +- crates/nu-command/src/commands/url_/scheme.rs | 2 +- crates/nu-command/src/commands/version.rs | 6 +- crates/nu-command/src/commands/where_.rs | 6 +- crates/nu-command/src/commands/which_.rs | 6 +- crates/nu-command/src/commands/with_env.rs | 6 +- crates/nu-command/src/commands/wrap.rs | 8 +- crates/nu-command/src/examples/double_echo.rs | 15 ++-- crates/nu-command/src/examples/double_ls.rs | 6 +- .../nu-command/src/examples/stub_generate.rs | 8 +- crates/nu-command/src/lib.rs | 2 +- crates/nu-command/src/prelude.rs | 55 +++++++++----- crates/nu-engine/src/evaluate/block.rs | 25 +++---- crates/nu-engine/src/evaluate/internal.rs | 73 ++++++++++++------- crates/nu-engine/src/evaluation_context.rs | 4 +- .../src/filesystem/filesystem_shell.rs | 34 ++++----- crates/nu-engine/src/plugin/run_plugin.rs | 62 +++++++++------- crates/nu-engine/src/script.rs | 9 +-- crates/nu-engine/src/shell/mod.rs | 18 ++--- crates/nu-engine/src/shell/shell_manager.rs | 18 ++--- crates/nu-engine/src/shell/value_shell.rs | 22 +++--- crates/nu-engine/src/whole_stream_command.rs | 38 ++++++++-- crates/nu-errors/src/lib.rs | 15 +++- crates/nu-protocol/src/value.rs | 4 + crates/nu-stream/src/lib.rs | 1 + crates/nu-stream/src/output.rs | 54 +++++++------- crates/nu-stream/src/prelude.rs | 24 +++++- 250 files changed, 1021 insertions(+), 915 deletions(-) diff --git a/crates/nu-cli/src/lib.rs b/crates/nu-cli/src/lib.rs index a90039144dba..58ad1d2a8dbb 100644 --- a/crates/nu-cli/src/lib.rs +++ b/crates/nu-cli/src/lib.rs @@ -30,7 +30,7 @@ pub use nu_data::config; pub use nu_data::dict::TaggedListBuilder; pub use nu_data::primitive; pub use nu_data::value; -pub use nu_stream::{InputStream, InterruptibleStream, OutputStream}; +pub use nu_stream::{ActionStream, InputStream, InterruptibleStream}; pub use nu_value_ext::ValueExt; pub use num_traits::cast::ToPrimitive; diff --git a/crates/nu-cli/src/prelude.rs b/crates/nu-cli/src/prelude.rs index c28a34522bcc..b7aea3727302 100644 --- a/crates/nu-cli/src/prelude.rs +++ b/crates/nu-cli/src/prelude.rs @@ -36,7 +36,7 @@ pub(crate) use nu_engine::Host; pub(crate) use nu_errors::ShellError; #[allow(unused_imports)] pub(crate) use nu_protocol::outln; -pub(crate) use nu_stream::OutputStream; +pub(crate) use nu_stream::ActionStream; #[allow(unused_imports)] pub(crate) use nu_value_ext::ValueExt; #[allow(unused_imports)] @@ -44,15 +44,15 @@ pub(crate) use std::sync::atomic::Ordering; #[allow(clippy::clippy::wrong_self_convention)] pub trait FromInputStream { - fn from_input_stream(self) -> OutputStream; + fn from_input_stream(self) -> ActionStream; } impl FromInputStream for T where T: Iterator + Send + Sync + 'static, { - fn from_input_stream(self) -> OutputStream { - OutputStream { + fn from_input_stream(self) -> ActionStream { + ActionStream { values: Box::new(self.map(nu_protocol::ReturnSuccess::value)), } } @@ -60,7 +60,7 @@ where #[allow(clippy::clippy::wrong_self_convention)] pub trait ToOutputStream { - fn to_output_stream(self) -> OutputStream; + fn to_output_stream(self) -> ActionStream; } impl ToOutputStream for T @@ -68,8 +68,8 @@ where T: Iterator + Send + Sync + 'static, U: Into, { - fn to_output_stream(self) -> OutputStream { - OutputStream { + fn to_output_stream(self) -> ActionStream { + ActionStream { values: Box::new(self.map(|item| item.into())), } } diff --git a/crates/nu-command/src/commands/all.rs b/crates/nu-command/src/commands/all.rs index 92637bb63449..b905887e1855 100644 --- a/crates/nu-command/src/commands/all.rs +++ b/crates/nu-command/src/commands/all.rs @@ -5,6 +5,7 @@ use nu_errors::ShellError; use nu_protocol::{ hir::CapturedBlock, hir::ClassifiedCommand, Signature, SyntaxShape, UntaggedValue, }; +use nu_stream::ToOutputStreamWithActions; pub struct Command; @@ -30,7 +31,7 @@ impl WholeStreamCommand for Command { "Find if the table rows matches the condition." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { all(args) } @@ -52,7 +53,7 @@ impl WholeStreamCommand for Command { } } -fn all(args: CommandArgs) -> Result { +fn all(args: CommandArgs) -> Result { let ctx = Arc::new(EvaluationContext::from_args(&args)); let tag = args.call_info.name_tag.clone(); let (Arguments { block }, input) = args.process()?; @@ -117,7 +118,7 @@ fn all(args: CommandArgs) -> Result { Err(e) => Err(e), } })? - .to_output_stream()) + .to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/ansi/command.rs b/crates/nu-command/src/commands/ansi/command.rs index f9f5da3e4d50..641ad835d48a 100644 --- a/crates/nu-command/src/commands/ansi/command.rs +++ b/crates/nu-command/src/commands/ansi/command.rs @@ -112,7 +112,7 @@ Format: # ] } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let args = args.evaluate_once()?; let code: Option, ShellError>> = args.opt(0); @@ -130,7 +130,7 @@ Format: # )); } let output = format!("\x1b[{}", e.item); - return Ok(OutputStream::one(ReturnSuccess::value( + return Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::string(output).into_value(e.tag()), ))); } @@ -149,7 +149,7 @@ Format: # //Operating system command aka osc ESC ] <- note the right brace, not left brace for osc // OCS's need to end with a bell '\x07' char let output = format!("\x1b]{};", o.item); - return Ok(OutputStream::one(ReturnSuccess::value( + return Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::string(output).into_value(o.tag()), ))); } @@ -159,7 +159,7 @@ Format: # let ansi_code = str_to_ansi(&code.item); if let Some(output) = ansi_code { - Ok(OutputStream::one(ReturnSuccess::value( + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::string(output).into_value(code.tag()), ))) } else { diff --git a/crates/nu-command/src/commands/ansi/strip.rs b/crates/nu-command/src/commands/ansi/strip.rs index 46001ff542f1..8235087b7c27 100644 --- a/crates/nu-command/src/commands/ansi/strip.rs +++ b/crates/nu-command/src/commands/ansi/strip.rs @@ -31,7 +31,7 @@ impl WholeStreamCommand for SubCommand { "strip ansi escape sequences from string" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args) } @@ -44,7 +44,7 @@ impl WholeStreamCommand for SubCommand { } } -fn operate(args: CommandArgs) -> Result { +fn operate(args: CommandArgs) -> Result { let (Arguments { rest }, input) = args.process()?; let column_paths: Vec<_> = rest; @@ -65,7 +65,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } fn action(input: &Value, tag: impl Into) -> Result { diff --git a/crates/nu-command/src/commands/any.rs b/crates/nu-command/src/commands/any.rs index 2c83e81db20f..ba902a14c32f 100644 --- a/crates/nu-command/src/commands/any.rs +++ b/crates/nu-command/src/commands/any.rs @@ -30,7 +30,7 @@ impl WholeStreamCommand for Command { "Find if the table rows matches the condition." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { any(args) } @@ -52,7 +52,7 @@ impl WholeStreamCommand for Command { } } -fn any(args: CommandArgs) -> Result { +fn any(args: CommandArgs) -> Result { let ctx = Arc::new(EvaluationContext::from_args(&args)); let tag = args.call_info.name_tag.clone(); let (Arguments { block }, input) = args.process()?; @@ -117,7 +117,7 @@ fn any(args: CommandArgs) -> Result { Err(e) => Err(e), } })? - .to_output_stream()) + .to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/append.rs b/crates/nu-command/src/commands/append.rs index e08107a87550..434586e8a7ef 100644 --- a/crates/nu-command/src/commands/append.rs +++ b/crates/nu-command/src/commands/append.rs @@ -27,7 +27,7 @@ impl WholeStreamCommand for Command { "Append a row to the table." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let (Arguments { mut value }, input) = args.process()?; let input: Vec = input.collect(); @@ -51,7 +51,7 @@ impl WholeStreamCommand for Command { .into_iter() .chain(vec![value]) .map(ReturnSuccess::value) - .to_output_stream()) + .to_output_stream_with_actions()) } fn examples(&self) -> Vec { diff --git a/crates/nu-command/src/commands/autoenv.rs b/crates/nu-command/src/commands/autoenv.rs index db931bc12fd3..476852385501 100644 --- a/crates/nu-command/src/commands/autoenv.rs +++ b/crates/nu-command/src/commands/autoenv.rs @@ -25,8 +25,8 @@ The .nu-env file has the same format as your $HOME/nu/config.toml file. By loadi fn signature(&self) -> Signature { Signature::build("autoenv") } - fn run(&self, args: CommandArgs) -> Result { - Ok(OutputStream::one(ReturnSuccess::value( + fn run_with_actions(&self, args: CommandArgs) -> Result { + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::string(get_full_help(&Autoenv, &args.scope)).into_value(Tag::unknown()), ))) } diff --git a/crates/nu-command/src/commands/autoenv_trust.rs b/crates/nu-command/src/commands/autoenv_trust.rs index d411d8e2ccc1..8163ccbcb314 100644 --- a/crates/nu-command/src/commands/autoenv_trust.rs +++ b/crates/nu-command/src/commands/autoenv_trust.rs @@ -21,7 +21,7 @@ impl WholeStreamCommand for AutoenvTrust { "Trust a .nu-env file in the current or given directory" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let ctx = EvaluationContext::from_args(&args); @@ -55,7 +55,7 @@ impl WholeStreamCommand for AutoenvTrust { })?; fs::write(config_path, tomlstr).expect("Couldn't write to toml file"); - Ok(OutputStream::one(ReturnSuccess::value( + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::string(".nu-env trusted!").into_value(tag), ))) } diff --git a/crates/nu-command/src/commands/autoenv_untrust.rs b/crates/nu-command/src/commands/autoenv_untrust.rs index 35c7f2fe5fa5..6cdf5383942c 100644 --- a/crates/nu-command/src/commands/autoenv_untrust.rs +++ b/crates/nu-command/src/commands/autoenv_untrust.rs @@ -25,7 +25,7 @@ impl WholeStreamCommand for AutoenvUnTrust { "Untrust a .nu-env file in the current or given directory" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let ctx = EvaluationContext::from_args(&args); let file_to_untrust = match args.call_info.evaluate(&ctx)?.args.nth(0) { @@ -79,7 +79,7 @@ impl WholeStreamCommand for AutoenvUnTrust { })?; fs::write(config_path, tomlstr).expect("Couldn't write to toml file"); - Ok(OutputStream::one(ReturnSuccess::value( + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::string(".nu-env untrusted!").into_value(tag), ))) } diff --git a/crates/nu-command/src/commands/autoview/command.rs b/crates/nu-command/src/commands/autoview/command.rs index 4eeb508497fd..95b24b2f7b33 100644 --- a/crates/nu-command/src/commands/autoview/command.rs +++ b/crates/nu-command/src/commands/autoview/command.rs @@ -80,7 +80,7 @@ pub fn autoview(context: CommandArgs) -> Result { ); let command_args = create_default_command_args(&context).with_input(stream); - let result = text.run(command_args)?; + let result = text.run_with_actions(command_args)?; let _ = result.collect::>(); } else { out!("{}", s); @@ -162,7 +162,7 @@ pub fn autoview(context: CommandArgs) -> Result { stream.push_back(x); let command_args = create_default_command_args(&context).with_input(stream); - let result = binary.run(command_args)?; + let result = binary.run_with_actions(command_args)?; let _ = result.collect::>(); } else { use pretty_hex::*; @@ -255,7 +255,7 @@ pub fn autoview(context: CommandArgs) -> Result { } } - Ok(OutputStream::empty()) + Ok(InputStream::empty()) } fn create_default_command_args(context: &RunnableContextWithoutInput) -> RawCommandArgs { diff --git a/crates/nu-command/src/commands/benchmark.rs b/crates/nu-command/src/commands/benchmark.rs index 190b8450e579..01a34479fcf3 100644 --- a/crates/nu-command/src/commands/benchmark.rs +++ b/crates/nu-command/src/commands/benchmark.rs @@ -47,7 +47,7 @@ impl WholeStreamCommand for Benchmark { "Runs a block and returns the time it took to execute it." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { benchmark(args) } @@ -67,7 +67,7 @@ impl WholeStreamCommand for Benchmark { } } -fn benchmark(raw_args: CommandArgs) -> Result { +fn benchmark(raw_args: CommandArgs) -> Result { let tag = raw_args.call_info.args.span; let mut context = EvaluationContext::from_args(&raw_args); let scope = raw_args.scope.clone(); @@ -134,10 +134,10 @@ fn benchmark_output( passthrough: Option, tag: T, context: &mut EvaluationContext, -) -> Result +) -> Result where T: Into + Copy, - Output: Into, + Output: Into, { let value = UntaggedValue::Row(Dictionary::from( indexmap @@ -161,7 +161,7 @@ where Ok(block_output.into()) } else { - let benchmark_output = OutputStream::one(value); + let benchmark_output = ActionStream::one(value); Ok(benchmark_output) } } diff --git a/crates/nu-command/src/commands/build_string.rs b/crates/nu-command/src/commands/build_string.rs index fe5949f3b644..ca4359e35503 100644 --- a/crates/nu-command/src/commands/build_string.rs +++ b/crates/nu-command/src/commands/build_string.rs @@ -21,7 +21,7 @@ impl WholeStreamCommand for BuildString { "Builds a string from the arguments." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let args = args.evaluate_once()?; let rest: Vec = args.rest(0)?; @@ -32,7 +32,7 @@ impl WholeStreamCommand for BuildString { output_string.push_str(&format_leaf(&r).plain_string(100_000)) } - Ok(OutputStream::one(ReturnSuccess::value( + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::string(output_string).into_value(tag), ))) } diff --git a/crates/nu-command/src/commands/cal.rs b/crates/nu-command/src/commands/cal.rs index 60d4441913d3..3c77ec17cf16 100644 --- a/crates/nu-command/src/commands/cal.rs +++ b/crates/nu-command/src/commands/cal.rs @@ -40,7 +40,7 @@ impl WholeStreamCommand for Cal { "Display a calendar." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { cal(args) } @@ -65,7 +65,7 @@ impl WholeStreamCommand for Cal { } } -pub fn cal(args: CommandArgs) -> Result { +pub fn cal(args: CommandArgs) -> Result { let args = args.evaluate_once()?; let mut calendar_vec_deque = VecDeque::new(); let tag = args.call_info.name_tag.clone(); @@ -101,7 +101,7 @@ pub fn cal(args: CommandArgs) -> Result { current_day_option, )?; - Ok(calendar_vec_deque.into_iter().to_output_stream()) + Ok(calendar_vec_deque.into_iter().to_output_stream_with_actions()) } fn get_invalid_year_shell_error(year_tag: &Tag) -> ShellError { diff --git a/crates/nu-command/src/commands/cd.rs b/crates/nu-command/src/commands/cd.rs index 772090fb5ca4..2a7498479ddb 100644 --- a/crates/nu-command/src/commands/cd.rs +++ b/crates/nu-command/src/commands/cd.rs @@ -24,7 +24,7 @@ impl WholeStreamCommand for Cd { "Change to a new path." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let shell_manager = args.shell_manager.clone(); let (args, _): (CdArgs, _) = args.process()?; diff --git a/crates/nu-command/src/commands/char_.rs b/crates/nu-command/src/commands/char_.rs index a2175021c909..da7edb2d87b9 100644 --- a/crates/nu-command/src/commands/char_.rs +++ b/crates/nu-command/src/commands/char_.rs @@ -57,7 +57,7 @@ impl WholeStreamCommand for Char { ] } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let args = args.evaluate_once()?; let name: Tagged = args.req(0)?; @@ -83,13 +83,13 @@ impl WholeStreamCommand for Char { Err(e) => return Err(e), } } - Ok(OutputStream::one(ReturnSuccess::value( + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::string(multi_byte).into_value(name.tag), ))) } else { let decoded_char = string_to_unicode_char(&name.item, &name.tag); if let Ok(ch) = decoded_char { - Ok(OutputStream::one(ReturnSuccess::value( + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::string(ch).into_value(name.tag()), ))) } else { @@ -103,7 +103,7 @@ impl WholeStreamCommand for Char { } else { let special_character = str_to_character(&name.item); if let Some(output) = special_character { - Ok(OutputStream::one(ReturnSuccess::value( + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::string(output).into_value(name.tag()), ))) } else { diff --git a/crates/nu-command/src/commands/chart.rs b/crates/nu-command/src/commands/chart.rs index fab5f17f54b9..8ae14bc1231c 100644 --- a/crates/nu-command/src/commands/chart.rs +++ b/crates/nu-command/src/commands/chart.rs @@ -19,14 +19,14 @@ impl WholeStreamCommand for Chart { "Displays charts." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { if args.scope.get_command("chart bar").is_none() { return Err(ShellError::untagged_runtime_error( "nu_plugin_chart not installed.", )); } - Ok(OutputStream::one(Ok(ReturnSuccess::Value( + Ok(ActionStream::one(Ok(ReturnSuccess::Value( UntaggedValue::string(get_full_help(&Chart, &args.scope)).into_value(Tag::unknown()), )))) } diff --git a/crates/nu-command/src/commands/clear.rs b/crates/nu-command/src/commands/clear.rs index 9f0cff5f640b..2b26dc306530 100644 --- a/crates/nu-command/src/commands/clear.rs +++ b/crates/nu-command/src/commands/clear.rs @@ -19,7 +19,7 @@ impl WholeStreamCommand for Clear { "Clears the terminal." } - fn run(&self, _: CommandArgs) -> Result { + fn run(&self, _: CommandArgs) -> Result { if cfg!(windows) { Command::new("cmd") .args(&["/C", "cls"]) @@ -31,7 +31,7 @@ impl WholeStreamCommand for Clear { .status() .expect("failed to execute process"); } - Ok(OutputStream::empty()) + Ok(InputStream::empty()) } fn examples(&self) -> Vec { diff --git a/crates/nu-command/src/commands/clip.rs b/crates/nu-command/src/commands/clip.rs index c4696f345cb9..6cb67cd7d1c4 100644 --- a/crates/nu-command/src/commands/clip.rs +++ b/crates/nu-command/src/commands/clip.rs @@ -21,7 +21,7 @@ impl WholeStreamCommand for Clip { "Copy the contents of the pipeline to the copy/paste buffer." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { clip(args) } @@ -41,9 +41,9 @@ impl WholeStreamCommand for Clip { } } -pub fn clip(args: CommandArgs) -> Result { +pub fn clip(args: CommandArgs) -> Result { let input = args.input; - let name = args.call_info.name_tag.clone(); + let name = args.call_info.name_tag; let values: Vec = input.collect(); if let Ok(mut clip_context) = Clipboard::new() { @@ -88,7 +88,7 @@ pub fn clip(args: CommandArgs) -> Result { name, )); } - Ok(OutputStream::empty()) + Ok(ActionStream::empty()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/compact.rs b/crates/nu-command/src/commands/compact.rs index 9576185fc829..44dff98c1c9e 100644 --- a/crates/nu-command/src/commands/compact.rs +++ b/crates/nu-command/src/commands/compact.rs @@ -25,7 +25,7 @@ impl WholeStreamCommand for Compact { "Creates a table with non-empty rows." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { compact(args) } @@ -38,7 +38,7 @@ impl WholeStreamCommand for Compact { } } -pub fn compact(args: CommandArgs) -> Result { +pub fn compact(args: CommandArgs) -> Result { let (CompactArgs { rest: columns }, input) = args.process()?; Ok(input .filter_map(move |item| { @@ -67,7 +67,7 @@ pub fn compact(args: CommandArgs) -> Result { } } }) - .to_output_stream()) + .to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/config/clear.rs b/crates/nu-command/src/commands/config/clear.rs index 86c5fe1f1ff3..53e4d7bb9e5e 100644 --- a/crates/nu-command/src/commands/config/clear.rs +++ b/crates/nu-command/src/commands/config/clear.rs @@ -18,7 +18,7 @@ impl WholeStreamCommand for SubCommand { "clear the config" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { clear(args) } @@ -31,14 +31,14 @@ impl WholeStreamCommand for SubCommand { } } -pub fn clear(args: CommandArgs) -> Result { +pub fn clear(args: CommandArgs) -> Result { let ctx = EvaluationContext::from_args(&args); let result = if let Some(global_cfg) = &mut args.configs.lock().global_config { global_cfg.vars.clear(); global_cfg.write()?; ctx.reload_config(global_cfg)?; - Ok(OutputStream::one(ReturnSuccess::value( + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::Row(global_cfg.vars.clone().into()).into_value(args.call_info.name_tag), ))) } else { @@ -46,7 +46,7 @@ pub fn clear(args: CommandArgs) -> Result { crate::commands::config::err_no_global_cfg_present(), ))] .into_iter() - .to_output_stream()) + .to_output_stream_with_actions()) }; result diff --git a/crates/nu-command/src/commands/config/command.rs b/crates/nu-command/src/commands/config/command.rs index 50bdd49d911a..c8e4e0f3404f 100644 --- a/crates/nu-command/src/commands/config/command.rs +++ b/crates/nu-command/src/commands/config/command.rs @@ -3,7 +3,7 @@ use nu_engine::CommandArgs; use nu_engine::WholeStreamCommand; use nu_errors::ShellError; use nu_protocol::{ReturnSuccess, Signature, UntaggedValue}; -use nu_stream::OutputStream; +use nu_stream::ActionStream; pub struct Command; @@ -20,7 +20,7 @@ impl WholeStreamCommand for Command { "Configuration management." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let name = args.call_info.name_tag; if let Some(global_cfg) = &args.configs.lock().global_config { @@ -29,13 +29,13 @@ impl WholeStreamCommand for Command { UntaggedValue::Row(result.into()).into_value(name), )] .into_iter() - .to_output_stream()) + .to_output_stream_with_actions()) } else { Ok(vec![ReturnSuccess::value(UntaggedValue::Error( crate::commands::config::err_no_global_cfg_present(), ))] .into_iter() - .to_output_stream()) + .to_output_stream_with_actions()) } } } diff --git a/crates/nu-command/src/commands/config/get.rs b/crates/nu-command/src/commands/config/get.rs index 56e3405bb8ea..bc3801fedfd2 100644 --- a/crates/nu-command/src/commands/config/get.rs +++ b/crates/nu-command/src/commands/config/get.rs @@ -27,7 +27,7 @@ impl WholeStreamCommand for SubCommand { "Gets a value from the config" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { get(args) } @@ -40,7 +40,7 @@ impl WholeStreamCommand for SubCommand { } } -pub fn get(args: CommandArgs) -> Result { +pub fn get(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let ctx = EvaluationContext::from_args(&args); @@ -53,15 +53,15 @@ pub fn get(args: CommandArgs) -> Result { Value { value: UntaggedValue::Table(list), .. - } => list.into_iter().to_output_stream(), - x => OutputStream::one(ReturnSuccess::value(x)), + } => list.into_iter().to_output_stream_with_actions(), + x => ActionStream::one(ReturnSuccess::value(x)), }) } else { Ok(vec![ReturnSuccess::value(UntaggedValue::Error( crate::commands::config::err_no_global_cfg_present(), ))] .into_iter() - .to_output_stream()) + .to_output_stream_with_actions()) }; result diff --git a/crates/nu-command/src/commands/config/path.rs b/crates/nu-command/src/commands/config/path.rs index c9f6c5c71442..5f7a5f725e77 100644 --- a/crates/nu-command/src/commands/config/path.rs +++ b/crates/nu-command/src/commands/config/path.rs @@ -18,7 +18,7 @@ impl WholeStreamCommand for SubCommand { "return the path to the config file" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { path(args) } @@ -31,9 +31,9 @@ impl WholeStreamCommand for SubCommand { } } -pub fn path(args: CommandArgs) -> Result { +pub fn path(args: CommandArgs) -> Result { if let Some(global_cfg) = &mut args.configs.lock().global_config { - Ok(OutputStream::one(ReturnSuccess::value( + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::Primitive(Primitive::FilePath(global_cfg.file_path.clone())), ))) } else { @@ -41,6 +41,6 @@ pub fn path(args: CommandArgs) -> Result { crate::commands::config::err_no_global_cfg_present(), ))] .into_iter() - .to_output_stream()) + .to_output_stream_with_actions()) } } diff --git a/crates/nu-command/src/commands/config/remove.rs b/crates/nu-command/src/commands/config/remove.rs index f28e20ddd25b..7049ed13258f 100644 --- a/crates/nu-command/src/commands/config/remove.rs +++ b/crates/nu-command/src/commands/config/remove.rs @@ -28,7 +28,7 @@ impl WholeStreamCommand for SubCommand { "Removes a value from the config" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { remove(args) } @@ -41,7 +41,7 @@ impl WholeStreamCommand for SubCommand { } } -pub fn remove(args: CommandArgs) -> Result { +pub fn remove(args: CommandArgs) -> Result { let ctx = EvaluationContext::from_args(&args); let (Arguments { remove }, _) = args.process()?; @@ -56,7 +56,7 @@ pub fn remove(args: CommandArgs) -> Result { UntaggedValue::row(global_cfg.vars.clone()).into_value(remove.tag()), )] .into_iter() - .to_output_stream()) + .to_output_stream_with_actions()) } else { Err(ShellError::labeled_error( "Key does not exist in config", @@ -69,7 +69,7 @@ pub fn remove(args: CommandArgs) -> Result { crate::commands::config::err_no_global_cfg_present(), ))] .into_iter() - .to_output_stream()) + .to_output_stream_with_actions()) }; result diff --git a/crates/nu-command/src/commands/config/set.rs b/crates/nu-command/src/commands/config/set.rs index e93faadffb57..4a88bcac7bb4 100644 --- a/crates/nu-command/src/commands/config/set.rs +++ b/crates/nu-command/src/commands/config/set.rs @@ -26,7 +26,7 @@ impl WholeStreamCommand for SubCommand { "Sets a value in the config" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { set(args) } @@ -56,7 +56,7 @@ impl WholeStreamCommand for SubCommand { } } -pub fn set(args: CommandArgs) -> Result { +pub fn set(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let ctx = EvaluationContext::from_args(&args); let ( @@ -85,11 +85,11 @@ pub fn set(args: CommandArgs) -> Result { global_cfg.write()?; ctx.reload_config(global_cfg)?; - Ok(OutputStream::one(ReturnSuccess::value( + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::row(global_cfg.vars.clone()).into_value(name), ))) } - Ok(_) => Ok(OutputStream::empty()), + Ok(_) => Ok(ActionStream::empty()), Err(reason) => Err(reason), } } else { @@ -97,7 +97,7 @@ pub fn set(args: CommandArgs) -> Result { crate::commands::config::err_no_global_cfg_present(), ))] .into_iter() - .to_output_stream()) + .to_output_stream_with_actions()) }; result diff --git a/crates/nu-command/src/commands/config/set_into.rs b/crates/nu-command/src/commands/config/set_into.rs index 51182d90f3bc..5b7dec52c55a 100644 --- a/crates/nu-command/src/commands/config/set_into.rs +++ b/crates/nu-command/src/commands/config/set_into.rs @@ -28,7 +28,7 @@ impl WholeStreamCommand for SubCommand { "Sets a value in the config" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { set_into(args) } @@ -41,7 +41,7 @@ impl WholeStreamCommand for SubCommand { } } -pub fn set_into(args: CommandArgs) -> Result { +pub fn set_into(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let ctx = EvaluationContext::from_args(&args); let (Arguments { set_into: v }, input) = args.process()?; @@ -71,7 +71,7 @@ pub fn set_into(args: CommandArgs) -> Result { global_cfg.write()?; ctx.reload_config(global_cfg)?; - Ok(OutputStream::one(ReturnSuccess::value( + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::row(global_cfg.vars.clone()).into_value(name), ))) } else { @@ -79,7 +79,7 @@ pub fn set_into(args: CommandArgs) -> Result { crate::commands::config::err_no_global_cfg_present(), ))] .into_iter() - .to_output_stream()) + .to_output_stream_with_actions()) }; result diff --git a/crates/nu-command/src/commands/cp.rs b/crates/nu-command/src/commands/cp.rs index 36cbe8398595..cca025a55d51 100644 --- a/crates/nu-command/src/commands/cp.rs +++ b/crates/nu-command/src/commands/cp.rs @@ -25,7 +25,7 @@ impl WholeStreamCommand for Cpy { "Copy files." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let shell_manager = args.shell_manager.clone(); let name = args.call_info.name_tag.clone(); let (args, _) = args.process()?; diff --git a/crates/nu-command/src/commands/date/command.rs b/crates/nu-command/src/commands/date/command.rs index 4342ead8f96a..7fc344f4827b 100644 --- a/crates/nu-command/src/commands/date/command.rs +++ b/crates/nu-command/src/commands/date/command.rs @@ -18,8 +18,8 @@ impl WholeStreamCommand for Command { "Apply date function." } - fn run(&self, args: CommandArgs) -> Result { - Ok(OutputStream::one(ReturnSuccess::value( + fn run_with_actions(&self, args: CommandArgs) -> Result { + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::string(get_full_help(&Command, &args.scope)).into_value(Tag::unknown()), ))) } diff --git a/crates/nu-command/src/commands/date/format.rs b/crates/nu-command/src/commands/date/format.rs index 83f1b632696d..bb9e110e707f 100644 --- a/crates/nu-command/src/commands/date/format.rs +++ b/crates/nu-command/src/commands/date/format.rs @@ -30,7 +30,7 @@ impl WholeStreamCommand for Date { "Format a given date using the given format string." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { format(args) } @@ -50,7 +50,7 @@ impl WholeStreamCommand for Date { } } -pub fn format(args: CommandArgs) -> Result { +pub fn format(args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let (FormatArgs { format, table }, input) = args.process()?; @@ -91,7 +91,7 @@ pub fn format(args: CommandArgs) -> Result { &tag, )), }) - .to_output_stream()) + .to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/date/list_timezone.rs b/crates/nu-command/src/commands/date/list_timezone.rs index b472d6ec6fc6..4597c8f2bece 100644 --- a/crates/nu-command/src/commands/date/list_timezone.rs +++ b/crates/nu-command/src/commands/date/list_timezone.rs @@ -20,7 +20,7 @@ impl WholeStreamCommand for Date { "List supported time zones." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { list_timezone(args) } @@ -40,7 +40,7 @@ impl WholeStreamCommand for Date { } } -fn list_timezone(args: CommandArgs) -> Result { +fn list_timezone(args: CommandArgs) -> Result { let args = args.evaluate_once()?; let tag = args.call_info.name_tag.clone(); @@ -57,7 +57,7 @@ fn list_timezone(args: CommandArgs) -> Result { )) }); - Ok(list.into_iter().to_output_stream()) + Ok(list.into_iter().to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/date/now.rs b/crates/nu-command/src/commands/date/now.rs index 063fe3f5321d..e31abbd08a20 100644 --- a/crates/nu-command/src/commands/date/now.rs +++ b/crates/nu-command/src/commands/date/now.rs @@ -19,12 +19,12 @@ impl WholeStreamCommand for Date { "Get the current date." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { now(args) } } -pub fn now(args: CommandArgs) -> Result { +pub fn now(args: CommandArgs) -> Result { let args = args.evaluate_once()?; let tag = args.call_info.name_tag.clone(); @@ -32,7 +32,7 @@ pub fn now(args: CommandArgs) -> Result { let value = UntaggedValue::date(now.with_timezone(now.offset())).into_value(&tag); - Ok(OutputStream::one(value)) + Ok(ActionStream::one(value)) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/date/to_table.rs b/crates/nu-command/src/commands/date/to_table.rs index 917933a80111..c366734d13e8 100644 --- a/crates/nu-command/src/commands/date/to_table.rs +++ b/crates/nu-command/src/commands/date/to_table.rs @@ -20,7 +20,7 @@ impl WholeStreamCommand for Date { "Print the date in a structured table." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { to_table(args) } @@ -33,7 +33,7 @@ impl WholeStreamCommand for Date { } } -fn to_table(args: CommandArgs) -> Result { +fn to_table(args: CommandArgs) -> Result { let args = args.evaluate_once()?; let tag = args.call_info.name_tag.clone(); let input = args.input; @@ -87,7 +87,7 @@ fn to_table(args: CommandArgs) -> Result { &tag, )), }) - .to_output_stream()) + .to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/date/to_timezone.rs b/crates/nu-command/src/commands/date/to_timezone.rs index 0a363c3e1b69..24657740248f 100644 --- a/crates/nu-command/src/commands/date/to_timezone.rs +++ b/crates/nu-command/src/commands/date/to_timezone.rs @@ -33,7 +33,7 @@ impl WholeStreamCommand for Date { "Use 'date list-timezone' to list all supported time zones." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { to_timezone(args) } @@ -58,7 +58,7 @@ impl WholeStreamCommand for Date { } } -fn to_timezone(args: CommandArgs) -> Result { +fn to_timezone(args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let (DateToTimeZoneArgs { timezone }, input) = args.process()?; @@ -85,7 +85,7 @@ fn to_timezone(args: CommandArgs) -> Result { &tag, )), }) - .to_output_stream()) + .to_output_stream_with_actions()) } fn error_message(err: ParseErrorKind) -> &'static str { diff --git a/crates/nu-command/src/commands/date/utc.rs b/crates/nu-command/src/commands/date/utc.rs index af222f59bb36..0c068788755f 100644 --- a/crates/nu-command/src/commands/date/utc.rs +++ b/crates/nu-command/src/commands/date/utc.rs @@ -21,7 +21,7 @@ impl WholeStreamCommand for Date { "return the current date in utc." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { utc(args) } } diff --git a/crates/nu-command/src/commands/debug.rs b/crates/nu-command/src/commands/debug.rs index 807272ac85d9..cb16977a3db3 100644 --- a/crates/nu-command/src/commands/debug.rs +++ b/crates/nu-command/src/commands/debug.rs @@ -23,12 +23,12 @@ impl WholeStreamCommand for Debug { "Print the Rust debug representation of the values." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { debug_value(args) } } -fn debug_value(args: CommandArgs) -> Result { +fn debug_value(args: CommandArgs) -> Result { let (DebugArgs { raw }, input) = args.process()?; Ok(input .map(move |v| { @@ -40,7 +40,7 @@ fn debug_value(args: CommandArgs) -> Result { ReturnSuccess::debug_value(v) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/def.rs b/crates/nu-command/src/commands/def.rs index 0a5b9424be5b..f247bd7a1ea5 100644 --- a/crates/nu-command/src/commands/def.rs +++ b/crates/nu-command/src/commands/def.rs @@ -34,11 +34,11 @@ impl WholeStreamCommand for Def { "Create a command and set it to a definition." } - fn run(&self, _args: CommandArgs) -> Result { + fn run_with_actions(&self, _args: CommandArgs) -> Result { // Currently, we don't do anything here because we should have already // installed the definition as we entered the scope // We just create a command so that we can get proper coloring - Ok(OutputStream::empty()) + Ok(ActionStream::empty()) } fn examples(&self) -> Vec { diff --git a/crates/nu-command/src/commands/default.rs b/crates/nu-command/src/commands/default.rs index 3e12781ce05a..b09be73c1d26 100644 --- a/crates/nu-command/src/commands/default.rs +++ b/crates/nu-command/src/commands/default.rs @@ -32,7 +32,7 @@ impl WholeStreamCommand for Default { "Sets a default row's column if missing." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { default(args) } @@ -45,7 +45,7 @@ impl WholeStreamCommand for Default { } } -fn default(args: CommandArgs) -> Result { +fn default(args: CommandArgs) -> Result { let (DefaultArgs { column, value }, input) = args.process()?; Ok(input @@ -67,7 +67,7 @@ fn default(args: CommandArgs) -> Result { ReturnSuccess::value(item) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/describe.rs b/crates/nu-command/src/commands/describe.rs index 98223172ab2e..33190469a289 100644 --- a/crates/nu-command/src/commands/describe.rs +++ b/crates/nu-command/src/commands/describe.rs @@ -22,12 +22,12 @@ impl WholeStreamCommand for Describe { "Describes the objects in the stream." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { describe(args) } } -pub fn describe(args: CommandArgs) -> Result { +pub fn describe(args: CommandArgs) -> Result { Ok(args .input .map(|row| { @@ -36,7 +36,7 @@ pub fn describe(args: CommandArgs) -> Result { UntaggedValue::string(name).into_value(Tag::unknown_anchor(row.tag.span)), ) }) - .to_output_stream()) + .to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/do_.rs b/crates/nu-command/src/commands/do_.rs index d4f0ab7de36d..0fb7e1b04a46 100644 --- a/crates/nu-command/src/commands/do_.rs +++ b/crates/nu-command/src/commands/do_.rs @@ -31,7 +31,7 @@ impl WholeStreamCommand for Do { "Runs a block, optionally ignoring errors." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { do_(args) } @@ -51,7 +51,7 @@ impl WholeStreamCommand for Do { } } -fn do_(raw_args: CommandArgs) -> Result { +fn do_(raw_args: CommandArgs) -> Result { let external_redirection = raw_args.call_info.args.external_redirection; let context = EvaluationContext::from_args(&raw_args); @@ -96,12 +96,12 @@ fn do_(raw_args: CommandArgs) -> Result { Ok(mut stream) => { let output = stream.drain_vec(); context.clear_errors(); - Ok(output.into_iter().to_output_stream()) + Ok(output.into_iter().to_output_stream_with_actions()) } - Err(_) => Ok(OutputStream::empty()), + Err(_) => Ok(ActionStream::empty()), } } else { - result.map(|x| x.to_output_stream()) + result.map(|x| x.to_output_stream_with_actions()) } } diff --git a/crates/nu-command/src/commands/drop/column.rs b/crates/nu-command/src/commands/drop/column.rs index 5a525eb57048..141c5ec34d03 100644 --- a/crates/nu-command/src/commands/drop/column.rs +++ b/crates/nu-command/src/commands/drop/column.rs @@ -29,7 +29,7 @@ impl WholeStreamCommand for SubCommand { "Remove the last number of columns. If you want to remove columns by name, try 'reject'." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { drop(args) } @@ -47,7 +47,7 @@ impl WholeStreamCommand for SubCommand { } } -fn drop(args: CommandArgs) -> Result { +fn drop(args: CommandArgs) -> Result { let (Arguments { columns }, input) = args.process()?; let to_drop = if let Some(quantity) = columns { @@ -69,7 +69,7 @@ fn drop(args: CommandArgs) -> Result { select_fields(&item, descs, item.tag()) }) .map(ReturnSuccess::value) - .to_output_stream()) + .to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/drop/command.rs b/crates/nu-command/src/commands/drop/command.rs index 02bc237dfbd1..c29656d5cabf 100644 --- a/crates/nu-command/src/commands/drop/command.rs +++ b/crates/nu-command/src/commands/drop/command.rs @@ -28,7 +28,7 @@ impl WholeStreamCommand for Command { "Remove the last number of rows or columns." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { drop(args) } @@ -51,7 +51,7 @@ impl WholeStreamCommand for Command { } } -fn drop(args: CommandArgs) -> Result { +fn drop(args: CommandArgs) -> Result { let (Arguments { rows }, input) = args.process()?; let v: Vec<_> = input.into_vec(); @@ -62,7 +62,7 @@ fn drop(args: CommandArgs) -> Result { }; Ok(if rows_to_drop == 0 { - v.into_iter().to_output_stream() + v.into_iter().to_output_stream_with_actions() } else { let k = if v.len() < rows_to_drop { 0 @@ -72,6 +72,6 @@ fn drop(args: CommandArgs) -> Result { let iter = v.into_iter().take(k); - iter.to_output_stream() + iter.to_output_stream_with_actions() }) } diff --git a/crates/nu-command/src/commands/du.rs b/crates/nu-command/src/commands/du.rs index 0d3a65a827e6..d3ab40d94c21 100644 --- a/crates/nu-command/src/commands/du.rs +++ b/crates/nu-command/src/commands/du.rs @@ -70,7 +70,7 @@ impl WholeStreamCommand for Du { "Find disk usage sizes of specified items." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { du(args) } @@ -83,7 +83,7 @@ impl WholeStreamCommand for Du { } } -fn du(args: CommandArgs) -> Result { +fn du(args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let ctrl_c = args.ctrl_c.clone(); let ctrl_c_copy = ctrl_c.clone(); @@ -150,7 +150,7 @@ fn du(args: CommandArgs) -> Result { Err(e) => vec![Err(e)], }) .interruptible(ctrl_c_copy) - .to_output_stream()) + .to_output_stream_with_actions()) } fn glob_err_into(e: GlobError) -> ShellError { diff --git a/crates/nu-command/src/commands/each/command.rs b/crates/nu-command/src/commands/each/command.rs index 52deca1683ef..aef0b9991ea8 100644 --- a/crates/nu-command/src/commands/each/command.rs +++ b/crates/nu-command/src/commands/each/command.rs @@ -90,7 +90,7 @@ pub fn process_row( context.scope.exit_scope(); - Ok(result?.to_output_stream()) + result } pub(crate) fn make_indexed_item(index: usize, item: Value) -> Value { @@ -121,7 +121,7 @@ fn each(raw_args: CommandArgs) -> Result { match process_row(block, context, row) { Ok(s) => s, - Err(e) => OutputStream::one(Err(e)), + Err(e) => OutputStream::one(Value::error(e)), } }) .flatten() @@ -135,7 +135,7 @@ fn each(raw_args: CommandArgs) -> Result { match process_row(block, context, input) { Ok(s) => s, - Err(e) => OutputStream::one(Err(e)), + Err(e) => OutputStream::one(Value::error(e)), } }) .flatten() diff --git a/crates/nu-command/src/commands/each/group.rs b/crates/nu-command/src/commands/each/group.rs index 05c46f8cd255..ee17580d2d54 100644 --- a/crates/nu-command/src/commands/each/group.rs +++ b/crates/nu-command/src/commands/each/group.rs @@ -2,9 +2,7 @@ use crate::commands::each::process_row; use crate::prelude::*; use nu_engine::WholeStreamCommand; use nu_errors::ShellError; -use nu_protocol::{ - hir::CapturedBlock, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value, -}; +use nu_protocol::{hir::CapturedBlock, Signature, SyntaxShape, UntaggedValue, Value}; use nu_source::Tagged; use serde::Deserialize; @@ -44,7 +42,7 @@ impl WholeStreamCommand for EachGroup { }] } - fn run(&self, raw_args: CommandArgs) -> Result { + fn run_with_actions(&self, raw_args: CommandArgs) -> Result { let context = Arc::new(EvaluationContext::from_args(&raw_args)); let (each_args, input): (EachGroupArgs, _) = raw_args.process()?; let block = Arc::new(Box::new(each_args.block)); @@ -56,7 +54,9 @@ impl WholeStreamCommand for EachGroup { input, }; - Ok(each_group_iterator.flatten().to_output_stream()) + Ok(each_group_iterator + .flatten() + .to_output_stream_with_actions()) } } @@ -122,20 +122,9 @@ pub(crate) fn run_block_on_vec( // If it returned multiple values, we need to put them into a table and // return that. - let result = vec.into_iter().collect::, _>>(); - let result_table = match result { - Ok(t) => t, - Err(e) => return OutputStream::one(Err(e)), - }; - - let table = result_table - .into_iter() - .filter_map(|x| x.raw_value()) - .collect(); - - OutputStream::one(Ok(ReturnSuccess::Value(UntaggedValue::Table(table).into()))) + OutputStream::one(UntaggedValue::Table(vec).into_untagged_value()) } - Err(e) => OutputStream::one(Err(e)), + Err(e) => OutputStream::one(Value::error(e)), } } diff --git a/crates/nu-command/src/commands/each/window.rs b/crates/nu-command/src/commands/each/window.rs index b008b351c8e9..36ea146796bf 100644 --- a/crates/nu-command/src/commands/each/window.rs +++ b/crates/nu-command/src/commands/each/window.rs @@ -49,7 +49,7 @@ impl WholeStreamCommand for EachWindow { }] } - fn run(&self, raw_args: CommandArgs) -> Result { + fn run_with_actions(&self, raw_args: CommandArgs) -> Result { let context = Arc::new(EvaluationContext::from_args(&raw_args)); let (each_args, mut input): (EachWindowArgs, _) = raw_args.process()?; let block = Arc::new(Box::new(each_args.block)); @@ -83,7 +83,7 @@ impl WholeStreamCommand for EachWindow { }) .filter_map(|x| x) .flatten() - .to_output_stream()) + .to_output_stream_with_actions()) } } diff --git a/crates/nu-command/src/commands/echo.rs b/crates/nu-command/src/commands/echo.rs index d14eeb275223..e30a4acaa052 100644 --- a/crates/nu-command/src/commands/echo.rs +++ b/crates/nu-command/src/commands/echo.rs @@ -3,9 +3,7 @@ use bigdecimal::Zero; use nu_engine::WholeStreamCommand; use nu_errors::ShellError; use nu_protocol::hir::Operator; -use nu_protocol::{ - Primitive, Range, RangeInclusion, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value, -}; +use nu_protocol::{Primitive, Range, RangeInclusion, Signature, SyntaxShape, UntaggedValue, Value}; pub struct Echo; @@ -22,7 +20,7 @@ impl WholeStreamCommand for Echo { "Echo the arguments back to the user." } - fn run(&self, args: CommandArgs) -> Result { + fn run(&self, args: CommandArgs) -> Result { echo(args) } @@ -42,31 +40,26 @@ impl WholeStreamCommand for Echo { } } -fn echo(args: CommandArgs) -> Result { +fn echo(args: CommandArgs) -> Result { let args = args.evaluate_once()?; let rest: Vec = args.rest(0)?; let stream = rest.into_iter().map(|i| match i.as_string() { - Ok(s) => OutputStream::one(Ok(ReturnSuccess::Value( - UntaggedValue::string(s).into_value(i.tag.clone()), - ))), + Ok(s) => InputStream::one(UntaggedValue::string(s).into_value(i.tag.clone())), _ => match i { Value { value: UntaggedValue::Table(table), .. - } => table - .into_iter() - .map(ReturnSuccess::value) - .to_output_stream(), + } => InputStream::from_stream(table.into_iter()), Value { value: UntaggedValue::Primitive(Primitive::Range(range)), tag, - } => RangeIterator::new(*range, tag).to_output_stream(), - x => OutputStream::one(Ok(ReturnSuccess::Value(x))), + } => InputStream::from_stream(RangeIterator::new(*range, tag)), + x => InputStream::one(x), }, }); - Ok(stream.flatten().to_output_stream()) + Ok(InputStream::from_stream(stream.flatten())) } struct RangeIterator { @@ -77,6 +70,7 @@ struct RangeIterator { moves_up: bool, one: UntaggedValue, negative_one: UntaggedValue, + done: bool, } impl RangeIterator { @@ -99,14 +93,18 @@ impl RangeIterator { is_end_inclusive: matches!(range.to.1, RangeInclusion::Inclusive), one: UntaggedValue::int(1), negative_one: UntaggedValue::int(-1), + done: false, } } } impl Iterator for RangeIterator { - type Item = Result; + type Item = Value; fn next(&mut self) -> Option { use std::cmp::Ordering; + if self.done { + return None; + } let ordering = if self.end == UntaggedValue::Primitive(Primitive::Nothing) { Ordering::Less @@ -129,11 +127,15 @@ impl Iterator for RangeIterator { UntaggedValue::Primitive(Primitive::Decimal(y)), ) => (BigDecimal::zero() + x).cmp(y), _ => { - return Some(Err(ShellError::labeled_error( - "Cannot create range", - "unsupported range", - self.tag.span, - ))) + self.done = true; + return Some( + UntaggedValue::Error(ShellError::labeled_error( + "Cannot create range", + "unsupported range", + self.tag.span, + )) + .into_untagged_value(), + ); } } }; @@ -147,15 +149,19 @@ impl Iterator for RangeIterator { Ok(result) => result, Err((left_type, right_type)) => { - return Some(Err(ShellError::coerce_error( - left_type.spanned(self.tag.span), - right_type.spanned(self.tag.span), - ))); + self.done = true; + return Some( + UntaggedValue::Error(ShellError::coerce_error( + left_type.spanned(self.tag.span), + right_type.spanned(self.tag.span), + )) + .into_untagged_value(), + ); } }; std::mem::swap(&mut self.curr, &mut next); - Some(ReturnSuccess::value(next.into_value(self.tag.clone()))) + Some(next.into_value(self.tag.clone())) } else if !self.moves_up && (ordering == Ordering::Greater || self.is_end_inclusive && ordering == Ordering::Equal) @@ -166,15 +172,19 @@ impl Iterator for RangeIterator { let mut next = match next_value { Ok(result) => result, Err((left_type, right_type)) => { - return Some(Err(ShellError::coerce_error( - left_type.spanned(self.tag.span), - right_type.spanned(self.tag.span), - ))); + self.done = true; + return Some( + UntaggedValue::Error(ShellError::coerce_error( + left_type.spanned(self.tag.span), + right_type.spanned(self.tag.span), + )) + .into_untagged_value(), + ); } }; std::mem::swap(&mut self.curr, &mut next); - Some(ReturnSuccess::value(next.into_value(self.tag.clone()))) + Some(next.into_value(self.tag.clone())) } else { None } diff --git a/crates/nu-command/src/commands/empty.rs b/crates/nu-command/src/commands/empty.rs index e2a697871496..93051339d682 100644 --- a/crates/nu-command/src/commands/empty.rs +++ b/crates/nu-command/src/commands/empty.rs @@ -33,7 +33,7 @@ impl WholeStreamCommand for Command { "Check for empty values." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { is_empty(args) } @@ -79,7 +79,7 @@ impl WholeStreamCommand for Command { } } -fn is_empty(args: CommandArgs) -> Result { +fn is_empty(args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let name_tag = Arc::new(args.call_info.name_tag.clone()); let context = Arc::new(EvaluationContext::from_args(&args)); @@ -100,11 +100,11 @@ fn is_empty(args: CommandArgs) -> Result { match process_row(context, input, block, columns, tag) { Ok(s) => s, - Err(e) => OutputStream::one(Err(e)), + Err(e) => ActionStream::one(Err(e)), } }) .flatten() - .to_output_stream()); + .to_output_stream_with_actions()); } Ok(input @@ -116,11 +116,11 @@ fn is_empty(args: CommandArgs) -> Result { match process_row(context, input, block, columns, tag) { Ok(s) => s, - Err(e) => OutputStream::one(Err(e)), + Err(e) => ActionStream::one(Err(e)), } }) .flatten() - .to_output_stream()) + .to_output_stream_with_actions()) } fn process_row( @@ -129,7 +129,7 @@ fn process_row( default_block: Arc>>, column_paths: Vec, tag: Arc, -) -> Result { +) -> Result { let _tag = &*tag; let mut out = Arc::new(None); let results = Arc::make_mut(&mut out); @@ -178,7 +178,7 @@ fn process_row( ref tag, } => { if column_paths.is_empty() { - Ok(OutputStream::one(ReturnSuccess::value({ + Ok(ActionStream::one(ReturnSuccess::value({ let is_empty = input.is_empty(); if default_block.is_some() { @@ -221,10 +221,10 @@ fn process_row( } } - Ok(OutputStream::one(ReturnSuccess::value(obj))) + Ok(ActionStream::one(ReturnSuccess::value(obj))) } } - other => Ok(OutputStream::one(ReturnSuccess::value({ + other => Ok(ActionStream::one(ReturnSuccess::value({ if other.is_empty() { results .clone() diff --git a/crates/nu-command/src/commands/enter.rs b/crates/nu-command/src/commands/enter.rs index 0789b36fb3e3..41dd40c2be8f 100644 --- a/crates/nu-command/src/commands/enter.rs +++ b/crates/nu-command/src/commands/enter.rs @@ -50,7 +50,7 @@ For a more complete list of encodings please refer to the encoding_rs documentation link at https://docs.rs/encoding_rs/0.8.28/encoding_rs/#statics"# } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { enter(args) } @@ -75,7 +75,7 @@ documentation link at https://docs.rs/encoding_rs/0.8.28/encoding_rs/#statics"# } } -fn enter(raw_args: CommandArgs) -> Result { +fn enter(raw_args: CommandArgs) -> Result { let scope = raw_args.scope.clone(); let shell_manager = raw_args.shell_manager.clone(); let head = raw_args.call_info.args.head.clone(); @@ -88,7 +88,7 @@ fn enter(raw_args: CommandArgs) -> Result { let location_string = location.display().to_string(); if location.is_dir() { - Ok(OutputStream::one(ReturnSuccess::action( + Ok(ActionStream::one(ReturnSuccess::action( CommandAction::EnterShell(location_string), ))) } else { @@ -129,8 +129,8 @@ fn enter(raw_args: CommandArgs) -> Result { scope, }; let tag = tagged_contents.tag.clone(); - let mut result = - converter.run(new_args.with_input(vec![tagged_contents]))?; + let mut result = converter + .run_with_actions(new_args.with_input(vec![tagged_contents]))?; let result_vec: Vec> = result.drain_vec(); Ok(result_vec .into_iter() @@ -143,19 +143,19 @@ fn enter(raw_args: CommandArgs) -> Result { ), x => x, }) - .to_output_stream()) + .to_output_stream_with_actions()) } else { - Ok(OutputStream::one(ReturnSuccess::action( + Ok(ActionStream::one(ReturnSuccess::action( CommandAction::EnterValueShell(tagged_contents), ))) } } else { - Ok(OutputStream::one(ReturnSuccess::action( + Ok(ActionStream::one(ReturnSuccess::action( CommandAction::EnterValueShell(tagged_contents), ))) } } - _ => Ok(OutputStream::one(ReturnSuccess::action( + _ => Ok(ActionStream::one(ReturnSuccess::action( CommandAction::EnterValueShell(tagged_contents), ))), } diff --git a/crates/nu-command/src/commands/every.rs b/crates/nu-command/src/commands/every.rs index c7124b034341..9a0c67122d96 100644 --- a/crates/nu-command/src/commands/every.rs +++ b/crates/nu-command/src/commands/every.rs @@ -35,7 +35,7 @@ impl WholeStreamCommand for Every { "Show (or skip) every n-th row, starting from the first one." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { every(args) } @@ -62,7 +62,7 @@ impl WholeStreamCommand for Every { } } -fn every(args: CommandArgs) -> Result { +fn every(args: CommandArgs) -> Result { let (EveryArgs { stride, skip }, input) = args.process()?; let stride = stride.item; @@ -80,7 +80,7 @@ fn every(args: CommandArgs) -> Result { None } }) - .to_output_stream()) + .to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/exec.rs b/crates/nu-command/src/commands/exec.rs index c7ef5af13efe..e927c148d10c 100644 --- a/crates/nu-command/src/commands/exec.rs +++ b/crates/nu-command/src/commands/exec.rs @@ -31,7 +31,7 @@ impl WholeStreamCommand for Exec { "Execute command." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { exec(args) } @@ -52,7 +52,7 @@ impl WholeStreamCommand for Exec { } #[cfg(unix)] -fn exec(args: CommandArgs) -> Result { +fn exec(args: CommandArgs) -> Result { use std::os::unix::process::CommandExt; use std::process::Command; diff --git a/crates/nu-command/src/commands/exit.rs b/crates/nu-command/src/commands/exit.rs index 9b10ebed3f4d..0b7435ba5bed 100644 --- a/crates/nu-command/src/commands/exit.rs +++ b/crates/nu-command/src/commands/exit.rs @@ -23,7 +23,7 @@ impl WholeStreamCommand for Exit { "Exit the current shell (or all shells)." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { exit(args) } @@ -43,7 +43,7 @@ impl WholeStreamCommand for Exit { } } -pub fn exit(args: CommandArgs) -> Result { +pub fn exit(args: CommandArgs) -> Result { let args = args.evaluate_once()?; let code = if let Some(value) = args.call_info.args.nth(0) { @@ -58,7 +58,7 @@ pub fn exit(args: CommandArgs) -> Result { CommandAction::LeaveShell(code) }; - Ok(OutputStream::one(ReturnSuccess::action(command_action))) + Ok(ActionStream::one(ReturnSuccess::action(command_action))) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/first.rs b/crates/nu-command/src/commands/first.rs index e437473b0d75..83230279a399 100644 --- a/crates/nu-command/src/commands/first.rs +++ b/crates/nu-command/src/commands/first.rs @@ -28,7 +28,7 @@ impl WholeStreamCommand for First { "Show only the first number of rows." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { first(args) } @@ -51,7 +51,7 @@ impl WholeStreamCommand for First { } } -fn first(args: CommandArgs) -> Result { +fn first(args: CommandArgs) -> Result { let (FirstArgs { rows }, input) = args.process()?; let rows_desired = if let Some(quantity) = rows { *quantity @@ -59,7 +59,7 @@ fn first(args: CommandArgs) -> Result { 1 }; - Ok(input.take(rows_desired).to_output_stream()) + Ok(input.take(rows_desired).to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/flatten.rs b/crates/nu-command/src/commands/flatten.rs index ad349117549d..ddfbf9712caf 100644 --- a/crates/nu-command/src/commands/flatten.rs +++ b/crates/nu-command/src/commands/flatten.rs @@ -26,7 +26,7 @@ impl WholeStreamCommand for Command { "Flatten the table." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { flatten(args) } @@ -51,14 +51,14 @@ impl WholeStreamCommand for Command { } } -fn flatten(args: CommandArgs) -> Result { +fn flatten(args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let (Arguments { rest: columns }, input) = args.process()?; Ok(input .map(move |item| flat_value(&columns, &item, &tag).into_iter()) .flatten() - .to_output_stream()) + .to_output_stream_with_actions()) } enum TableInside<'a> { diff --git a/crates/nu-command/src/commands/format/command.rs b/crates/nu-command/src/commands/format/command.rs index 451e6d12a243..fd25e5d46198 100644 --- a/crates/nu-command/src/commands/format/command.rs +++ b/crates/nu-command/src/commands/format/command.rs @@ -30,7 +30,7 @@ impl WholeStreamCommand for Format { "Format columns into a string using a simple pattern." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { format_command(args) } @@ -43,7 +43,7 @@ impl WholeStreamCommand for Format { } } -fn format_command(args: CommandArgs) -> Result { +fn format_command(args: CommandArgs) -> Result { let ctx = Arc::new(EvaluationContext::from_args(&args)); let (FormatArgs { pattern }, input) = args.process()?; @@ -84,7 +84,7 @@ fn format_command(args: CommandArgs) -> Result { ReturnSuccess::value(UntaggedValue::string(output).into_untagged_value()) }) - .to_output_stream()) + .to_output_stream_with_actions()) } #[derive(Debug)] diff --git a/crates/nu-command/src/commands/format/format_filesize.rs b/crates/nu-command/src/commands/format/format_filesize.rs index b457d0f3c821..77d60038bec3 100644 --- a/crates/nu-command/src/commands/format/format_filesize.rs +++ b/crates/nu-command/src/commands/format/format_filesize.rs @@ -39,7 +39,7 @@ impl WholeStreamCommand for FileSize { "Converts a column of filesizes to some specified format" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { filesize(args) } @@ -63,7 +63,7 @@ fn process_row( input: Value, format: Tagged, field: Arc, -) -> Result { +) -> Result { Ok({ let replace_for = get_data_by_column_path(&input, &field, move |_, _, error| error); match replace_for { @@ -75,7 +75,7 @@ fn process_row( { let byte_format = InlineShape::format_bytes(&fs, Some(&format.item)); let byte_value = Value::from(byte_format.1); - OutputStream::one(ReturnSuccess::value( + ActionStream::one(ReturnSuccess::value( input.replace_data_at_column_path(&field, byte_value).expect("Given that the existence check was already done, this shouldn't trigger never"), )) } else { @@ -86,12 +86,12 @@ fn process_row( )); } } - Err(e) => OutputStream::one(Err(e)), + Err(e) => ActionStream::one(Err(e)), } }) } -fn filesize(raw_args: CommandArgs) -> Result { +fn filesize(raw_args: CommandArgs) -> Result { let (Arguments { field, format }, input) = raw_args.process()?; let field = Arc::new(field); @@ -102,11 +102,11 @@ fn filesize(raw_args: CommandArgs) -> Result { match process_row(input, format, field) { Ok(s) => s, - Err(e) => OutputStream::one(Err(e)), + Err(e) => ActionStream::one(Err(e)), } }) .flatten() - .to_output_stream()) + .to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/from.rs b/crates/nu-command/src/commands/from.rs index 02b7f4efdbea..23557029e8d0 100644 --- a/crates/nu-command/src/commands/from.rs +++ b/crates/nu-command/src/commands/from.rs @@ -18,8 +18,8 @@ impl WholeStreamCommand for From { "Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)." } - fn run(&self, args: CommandArgs) -> Result { - Ok(OutputStream::one(ReturnSuccess::value( + fn run_with_actions(&self, args: CommandArgs) -> Result { + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::string(get_full_help(&From, &args.scope)).into_value(Tag::unknown()), ))) } diff --git a/crates/nu-command/src/commands/from_csv.rs b/crates/nu-command/src/commands/from_csv.rs index 0843c7962a8d..2a21a0cb3d5a 100644 --- a/crates/nu-command/src/commands/from_csv.rs +++ b/crates/nu-command/src/commands/from_csv.rs @@ -36,7 +36,7 @@ impl WholeStreamCommand for FromCsv { "Parse text as .csv and create table." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { from_csv(args) } @@ -66,7 +66,7 @@ impl WholeStreamCommand for FromCsv { } } -fn from_csv(args: CommandArgs) -> Result { +fn from_csv(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let ( diff --git a/crates/nu-command/src/commands/from_delimited_data.rs b/crates/nu-command/src/commands/from_delimited_data.rs index 1a78afc7048e..a5d59e1b0c5f 100644 --- a/crates/nu-command/src/commands/from_delimited_data.rs +++ b/crates/nu-command/src/commands/from_delimited_data.rs @@ -51,7 +51,7 @@ pub fn from_delimited_data( format_name: &'static str, input: InputStream, name: Tag, -) -> Result { +) -> Result { let name_tag = name; let concat_string = input.collect_string(name_tag.clone())?; let sample_lines = concat_string.item.lines().take(3).collect_vec().join("\n"); @@ -61,8 +61,8 @@ pub fn from_delimited_data( Value { value: UntaggedValue::Table(list), .. - } => Ok(list.into_iter().to_output_stream()), - x => Ok(OutputStream::one(x)), + } => Ok(list.into_iter().to_output_stream_with_actions()), + x => Ok(ActionStream::one(x)), }, Err(err) => { let line_one = match pretty_csv_error(err) { diff --git a/crates/nu-command/src/commands/from_eml.rs b/crates/nu-command/src/commands/from_eml.rs index 2c4f053d8474..d85419976e3d 100644 --- a/crates/nu-command/src/commands/from_eml.rs +++ b/crates/nu-command/src/commands/from_eml.rs @@ -34,7 +34,7 @@ impl WholeStreamCommand for FromEml { "Parse text as .eml and create table." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { from_eml(args) } } @@ -72,7 +72,7 @@ fn headerfieldvalue_to_value(tag: &Tag, value: &HeaderFieldValue) -> UntaggedVal } } -fn from_eml(args: CommandArgs) -> Result { +fn from_eml(args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let (eml_args, input): (FromEmlArgs, _) = args.process()?; let value = input.collect_string(tag.clone())?; @@ -115,7 +115,7 @@ fn from_eml(args: CommandArgs) -> Result { dict.insert_untagged("Body", UntaggedValue::string(body)); } - Ok(OutputStream::one(ReturnSuccess::value(dict.into_value()))) + Ok(ActionStream::one(ReturnSuccess::value(dict.into_value()))) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/from_ics.rs b/crates/nu-command/src/commands/from_ics.rs index b46d56ad7578..9bd64a810949 100644 --- a/crates/nu-command/src/commands/from_ics.rs +++ b/crates/nu-command/src/commands/from_ics.rs @@ -22,12 +22,12 @@ impl WholeStreamCommand for FromIcs { "Parse text as .ics and create table." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { from_ics(args) } } -fn from_ics(args: CommandArgs) -> Result { +fn from_ics(args: CommandArgs) -> Result { let args = args.evaluate_once()?; let tag = args.name_tag(); let input = args.input; @@ -52,7 +52,7 @@ fn from_ics(args: CommandArgs) -> Result { } } - Ok(output.into_iter().to_output_stream()) + Ok(output.into_iter().to_output_stream_with_actions()) } fn calendar_to_value(calendar: IcalCalendar, tag: Tag) -> Value { diff --git a/crates/nu-command/src/commands/from_ini.rs b/crates/nu-command/src/commands/from_ini.rs index 960a7e78cfa4..cfa660bfef8a 100644 --- a/crates/nu-command/src/commands/from_ini.rs +++ b/crates/nu-command/src/commands/from_ini.rs @@ -19,7 +19,7 @@ impl WholeStreamCommand for FromIni { "Parse text as .ini and create table" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { from_ini(args) } } @@ -59,7 +59,7 @@ pub fn from_ini_string_to_value( Ok(convert_ini_top_to_nu_value(&v, tag)) } -fn from_ini(args: CommandArgs) -> Result { +fn from_ini(args: CommandArgs) -> Result { let args = args.evaluate_once()?; let tag = args.name_tag(); let input = args.input; @@ -70,8 +70,8 @@ fn from_ini(args: CommandArgs) -> Result { Value { value: UntaggedValue::Table(list), .. - } => Ok(list.into_iter().to_output_stream()), - x => Ok(OutputStream::one(x)), + } => Ok(list.into_iter().to_output_stream_with_actions()), + x => Ok(ActionStream::one(x)), }, Err(_) => Err(ShellError::labeled_error_with_secondary( "Could not parse as INI", diff --git a/crates/nu-command/src/commands/from_json.rs b/crates/nu-command/src/commands/from_json.rs index 273686c29791..d47323b47cc3 100644 --- a/crates/nu-command/src/commands/from_json.rs +++ b/crates/nu-command/src/commands/from_json.rs @@ -27,7 +27,7 @@ impl WholeStreamCommand for FromJson { "Parse text as .json and create table." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { from_json(args) } } @@ -67,7 +67,7 @@ pub fn from_json_string_to_value(s: String, tag: impl Into) -> nu_json::Res Ok(convert_json_value_to_nu_value(&v, tag)) } -fn from_json(args: CommandArgs) -> Result { +fn from_json(args: CommandArgs) -> Result { let name_tag = args.call_info.name_tag.clone(); let (FromJsonArgs { objects }, input) = args.process()?; @@ -100,7 +100,7 @@ fn from_json(args: CommandArgs) -> Result { } } }) - .to_output_stream()) + .to_output_stream_with_actions()) } else { match from_json_string_to_value(concat_string.item, name_tag.clone()) { Ok(x) => match x { @@ -110,16 +110,16 @@ fn from_json(args: CommandArgs) -> Result { } => Ok(list .into_iter() .map(ReturnSuccess::value) - .to_output_stream()), + .to_output_stream_with_actions()), - x => Ok(OutputStream::one(ReturnSuccess::value(x))), + x => Ok(ActionStream::one(ReturnSuccess::value(x))), }, Err(e) => { let mut message = "Could not parse as JSON (".to_string(); message.push_str(&e.to_string()); message.push(')'); - Ok(OutputStream::one(Err( + Ok(ActionStream::one(Err( ShellError::labeled_error_with_secondary( message, "input cannot be parsed as JSON", diff --git a/crates/nu-command/src/commands/from_ods.rs b/crates/nu-command/src/commands/from_ods.rs index 31ebb970de94..4929c2f5f76e 100644 --- a/crates/nu-command/src/commands/from_ods.rs +++ b/crates/nu-command/src/commands/from_ods.rs @@ -30,12 +30,12 @@ impl WholeStreamCommand for FromOds { "Parse OpenDocument Spreadsheet(.ods) data and create table." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { from_ods(args) } } -fn from_ods(args: CommandArgs) -> Result { +fn from_ods(args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let span = tag.span; @@ -87,7 +87,7 @@ fn from_ods(args: CommandArgs) -> Result { } } - Ok(OutputStream::one(ReturnSuccess::value(dict.into_value()))) + Ok(ActionStream::one(ReturnSuccess::value(dict.into_value()))) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/from_ssv.rs b/crates/nu-command/src/commands/from_ssv.rs index 93da78fdfcbe..8770347310a5 100644 --- a/crates/nu-command/src/commands/from_ssv.rs +++ b/crates/nu-command/src/commands/from_ssv.rs @@ -45,7 +45,7 @@ impl WholeStreamCommand for FromSsv { "Parse text as space-separated values and create a table. The default minimum number of spaces counted as a separator is 2." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { from_ssv(args) } } @@ -246,7 +246,7 @@ fn from_ssv_string_to_value( UntaggedValue::Table(rows).into_value(&tag) } -fn from_ssv(args: CommandArgs) -> Result { +fn from_ssv(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let ( FromSsvArgs { @@ -276,8 +276,8 @@ fn from_ssv(args: CommandArgs) -> Result { } => list .into_iter() .map(ReturnSuccess::value) - .to_output_stream(), - x => OutputStream::one(ReturnSuccess::value(x)), + .to_output_stream_with_actions(), + x => ActionStream::one(ReturnSuccess::value(x)), }, ) } diff --git a/crates/nu-command/src/commands/from_toml.rs b/crates/nu-command/src/commands/from_toml.rs index 6ab512cf284d..85692c1f4eda 100644 --- a/crates/nu-command/src/commands/from_toml.rs +++ b/crates/nu-command/src/commands/from_toml.rs @@ -18,7 +18,7 @@ impl WholeStreamCommand for FromToml { "Parse text as .toml and create table." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { from_toml(args) } } @@ -60,7 +60,7 @@ pub fn from_toml_string_to_value(s: String, tag: impl Into) -> Result Result { +pub fn from_toml(args: CommandArgs) -> Result { let args = args.evaluate_once()?; let tag = args.name_tag(); let input = args.input; @@ -75,8 +75,8 @@ pub fn from_toml(args: CommandArgs) -> Result { } => list .into_iter() .map(ReturnSuccess::value) - .to_output_stream(), - x => OutputStream::one(ReturnSuccess::value(x)), + .to_output_stream_with_actions(), + x => ActionStream::one(ReturnSuccess::value(x)), }, Err(_) => { return Err(ShellError::labeled_error_with_secondary( diff --git a/crates/nu-command/src/commands/from_tsv.rs b/crates/nu-command/src/commands/from_tsv.rs index 5b9036dea6c8..8b3df8aed121 100644 --- a/crates/nu-command/src/commands/from_tsv.rs +++ b/crates/nu-command/src/commands/from_tsv.rs @@ -28,12 +28,12 @@ impl WholeStreamCommand for FromTsv { "Parse text as .tsv and create table." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { from_tsv(args) } } -fn from_tsv(args: CommandArgs) -> Result { +fn from_tsv(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let (FromTsvArgs { noheaders }, input) = args.process()?; diff --git a/crates/nu-command/src/commands/from_url.rs b/crates/nu-command/src/commands/from_url.rs index 2405463c8efa..9b5fd3331705 100644 --- a/crates/nu-command/src/commands/from_url.rs +++ b/crates/nu-command/src/commands/from_url.rs @@ -18,12 +18,12 @@ impl WholeStreamCommand for FromUrl { "Parse url-encoded string as a table." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { from_url(args) } } -fn from_url(args: CommandArgs) -> Result { +fn from_url(args: CommandArgs) -> Result { let args = args.evaluate_once()?; let tag = args.name_tag(); let input = args.input; @@ -40,7 +40,7 @@ fn from_url(args: CommandArgs) -> Result { row.insert_untagged(k, UntaggedValue::string(v)); } - Ok(OutputStream::one(ReturnSuccess::value(row.into_value()))) + Ok(ActionStream::one(ReturnSuccess::value(row.into_value()))) } _ => Err(ShellError::labeled_error_with_secondary( "String not compatible with url-encoding", diff --git a/crates/nu-command/src/commands/from_vcf.rs b/crates/nu-command/src/commands/from_vcf.rs index 895ca06e5d55..241609fa45a2 100644 --- a/crates/nu-command/src/commands/from_vcf.rs +++ b/crates/nu-command/src/commands/from_vcf.rs @@ -21,12 +21,12 @@ impl WholeStreamCommand for FromVcf { "Parse text as .vcf and create table." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { from_vcf(args) } } -fn from_vcf(args: CommandArgs) -> Result { +fn from_vcf(args: CommandArgs) -> Result { let args = args.evaluate_once()?; let tag = args.name_tag(); let input = args.input; @@ -47,7 +47,7 @@ fn from_vcf(args: CommandArgs) -> Result { let collected: Vec<_> = iter.collect(); - Ok(collected.into_iter().to_output_stream()) + Ok(collected.into_iter().to_output_stream_with_actions()) } fn contact_to_value(contact: VcardContact, tag: Tag) -> Value { diff --git a/crates/nu-command/src/commands/from_xlsx.rs b/crates/nu-command/src/commands/from_xlsx.rs index 0efe82bfe710..6f5869efcb5a 100644 --- a/crates/nu-command/src/commands/from_xlsx.rs +++ b/crates/nu-command/src/commands/from_xlsx.rs @@ -30,12 +30,12 @@ impl WholeStreamCommand for FromXlsx { "Parse binary Excel(.xlsx) data and create table." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { from_xlsx(args) } } -fn from_xlsx(args: CommandArgs) -> Result { +fn from_xlsx(args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let span = tag.span; let ( @@ -87,7 +87,7 @@ fn from_xlsx(args: CommandArgs) -> Result { } } - Ok(OutputStream::one(ReturnSuccess::value(dict.into_value()))) + Ok(ActionStream::one(ReturnSuccess::value(dict.into_value()))) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/from_xml.rs b/crates/nu-command/src/commands/from_xml.rs index 96809c7766ad..85c07204d6f0 100644 --- a/crates/nu-command/src/commands/from_xml.rs +++ b/crates/nu-command/src/commands/from_xml.rs @@ -18,7 +18,7 @@ impl WholeStreamCommand for FromXml { "Parse text as .xml and create table." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { from_xml(args) } } @@ -94,7 +94,7 @@ pub fn from_xml_string_to_value(s: String, tag: impl Into) -> Result Result { +fn from_xml(args: CommandArgs) -> Result { let args = args.evaluate_once()?; let tag = args.name_tag(); let input = args.input; @@ -110,8 +110,8 @@ fn from_xml(args: CommandArgs) -> Result { } => list .into_iter() .map(ReturnSuccess::value) - .to_output_stream(), - x => OutputStream::one(ReturnSuccess::value(x)), + .to_output_stream_with_actions(), + x => ActionStream::one(ReturnSuccess::value(x)), }, Err(_) => { return Err(ShellError::labeled_error_with_secondary( diff --git a/crates/nu-command/src/commands/from_yaml.rs b/crates/nu-command/src/commands/from_yaml.rs index d3a183a69751..d2cf22859b7c 100644 --- a/crates/nu-command/src/commands/from_yaml.rs +++ b/crates/nu-command/src/commands/from_yaml.rs @@ -18,7 +18,7 @@ impl WholeStreamCommand for FromYaml { "Parse text as .yaml/.yml and create table." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { from_yaml(args) } } @@ -38,7 +38,7 @@ impl WholeStreamCommand for FromYml { "Parse text as .yaml/.yml and create table." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { from_yaml(args) } } @@ -131,7 +131,7 @@ pub fn from_yaml_string_to_value(s: String, tag: impl Into) -> Result Result { +fn from_yaml(args: CommandArgs) -> Result { let args = args.evaluate_once()?; let tag = args.name_tag(); let input = args.input; @@ -143,8 +143,8 @@ fn from_yaml(args: CommandArgs) -> Result { Value { value: UntaggedValue::Table(list), .. - } => Ok(list.into_iter().to_output_stream()), - x => Ok(OutputStream::one(x)), + } => Ok(list.into_iter().to_output_stream_with_actions()), + x => Ok(ActionStream::one(x)), }, Err(_) => Err(ShellError::labeled_error_with_secondary( "Could not parse as YAML", diff --git a/crates/nu-command/src/commands/get.rs b/crates/nu-command/src/commands/get.rs index d1fd5b9254a0..e97618774c97 100644 --- a/crates/nu-command/src/commands/get.rs +++ b/crates/nu-command/src/commands/get.rs @@ -34,7 +34,7 @@ impl WholeStreamCommand for Command { "Open given cells as text." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { get(args) } @@ -54,7 +54,7 @@ impl WholeStreamCommand for Command { } } -pub fn get(args: CommandArgs) -> Result { +pub fn get(args: CommandArgs) -> Result { let (Arguments { mut rest }, mut input) = args.process()?; let (column_paths, _) = arguments(&mut rest)?; @@ -66,7 +66,7 @@ pub fn get(args: CommandArgs) -> Result { Ok(descs .into_iter() .map(ReturnSuccess::value) - .to_output_stream()) + .to_output_stream_with_actions()) } else { trace!("get {:?}", column_paths); let output_stream = input @@ -78,7 +78,7 @@ pub fn get(args: CommandArgs) -> Result { .collect::>() }) .flatten() - .to_output_stream(); + .to_output_stream_with_actions(); Ok(output_stream) } } diff --git a/crates/nu-command/src/commands/group_by.rs b/crates/nu-command/src/commands/group_by.rs index af84db7810c4..32b28b8a4371 100644 --- a/crates/nu-command/src/commands/group_by.rs +++ b/crates/nu-command/src/commands/group_by.rs @@ -2,7 +2,7 @@ use crate::prelude::*; use crate::utils::suggestions::suggestions; use nu_engine::WholeStreamCommand; use nu_errors::ShellError; -use nu_protocol::{ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value}; +use nu_protocol::{Signature, SyntaxShape, UntaggedValue, Value}; use nu_source::Tagged; use nu_value_ext::as_string; @@ -150,7 +150,7 @@ pub fn group_by(args: CommandArgs) -> Result { match crate::commands::each::process_row(run, context, value.clone()) { Ok(mut s) => { - let collection: Vec> = s.drain_vec(); + let collection: Vec = s.drain_vec(); if collection.len() > 1 { return Err(ShellError::labeled_error( @@ -161,14 +161,12 @@ pub fn group_by(args: CommandArgs) -> Result { } let value = match collection.get(0) { - Some(Ok(return_value)) => { - return_value.raw_value().unwrap_or_else(|| { - UntaggedValue::string(error_key).into_value(&name) - }) - } - Some(Err(_)) | None => { - UntaggedValue::string(error_key).into_value(&name) - } + Some(Value { + value: UntaggedValue::Error(_), + .. + }) + | None => UntaggedValue::string(error_key).into_value(&name), + Some(return_value) => return_value.clone(), }; keys.push(as_string(&value)); @@ -220,7 +218,7 @@ pub fn group_by(args: CommandArgs) -> Result { Grouper::ByColumn(column_name) => group(&column_name, &values, &name), }; - Ok(OutputStream::one(ReturnSuccess::value(group_value?))) + Ok(OutputStream::one(group_value?)) } pub fn group( diff --git a/crates/nu-command/src/commands/group_by_date.rs b/crates/nu-command/src/commands/group_by_date.rs index 190dce434639..14d9fb403e61 100644 --- a/crates/nu-command/src/commands/group_by_date.rs +++ b/crates/nu-command/src/commands/group_by_date.rs @@ -37,7 +37,7 @@ impl WholeStreamCommand for GroupByDate { "creates a table grouped by date." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { group_by_date(args) } @@ -58,7 +58,7 @@ enum GroupByColumn { Name(Option>), } -pub fn group_by_date(args: CommandArgs) -> Result { +pub fn group_by_date(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let ( GroupByDateArgs { @@ -125,7 +125,7 @@ pub fn group_by_date(args: CommandArgs) -> Result { } }; - Ok(OutputStream::one(ReturnSuccess::value(value_result?))) + Ok(ActionStream::one(ReturnSuccess::value(value_result?))) } } diff --git a/crates/nu-command/src/commands/hash_/base64_.rs b/crates/nu-command/src/commands/hash_/base64_.rs index 77bc68627171..18adf189f19b 100644 --- a/crates/nu-command/src/commands/hash_/base64_.rs +++ b/crates/nu-command/src/commands/hash_/base64_.rs @@ -64,7 +64,7 @@ impl WholeStreamCommand for SubCommand { "base64 encode or decode a value" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args) } @@ -95,7 +95,7 @@ impl WholeStreamCommand for SubCommand { } } -fn operate(args: CommandArgs) -> Result { +fn operate(args: CommandArgs) -> Result { let name_tag = args.call_info.name_tag.clone(); let ( @@ -109,7 +109,7 @@ fn operate(args: CommandArgs) -> Result { ) = args.process()?; if encode.item && decode.item { - return Ok(OutputStream::one(Err(ShellError::labeled_error( + return Ok(ActionStream::one(Err(ShellError::labeled_error( "only one of --decode and --encode flags can be used", "conflicting flags", name_tag, @@ -154,7 +154,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } fn action( diff --git a/crates/nu-command/src/commands/hash_/command.rs b/crates/nu-command/src/commands/hash_/command.rs index 53e10b635ff1..8a8d0a0f861d 100644 --- a/crates/nu-command/src/commands/hash_/command.rs +++ b/crates/nu-command/src/commands/hash_/command.rs @@ -21,8 +21,8 @@ impl WholeStreamCommand for Command { "Apply hash function." } - fn run(&self, args: CommandArgs) -> Result { - Ok(OutputStream::one(ReturnSuccess::value( + fn run_with_actions(&self, args: CommandArgs) -> Result { + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::string(get_full_help(&Command, &args.scope)).into_value(Tag::unknown()), ))) } diff --git a/crates/nu-command/src/commands/hash_/md5_.rs b/crates/nu-command/src/commands/hash_/md5_.rs index 018eb101b162..e14da4310084 100644 --- a/crates/nu-command/src/commands/hash_/md5_.rs +++ b/crates/nu-command/src/commands/hash_/md5_.rs @@ -30,7 +30,7 @@ impl WholeStreamCommand for SubCommand { "md5 encode a value" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args) } @@ -56,7 +56,7 @@ impl WholeStreamCommand for SubCommand { } } -fn operate(args: CommandArgs) -> Result { +fn operate(args: CommandArgs) -> Result { let (Arguments { rest }, input) = args.process()?; let column_paths: Vec<_> = rest; @@ -78,7 +78,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } fn action(input: &Value, tag: impl Into) -> Result { diff --git a/crates/nu-command/src/commands/headers.rs b/crates/nu-command/src/commands/headers.rs index f3f790cc4d84..2b4f070ee262 100644 --- a/crates/nu-command/src/commands/headers.rs +++ b/crates/nu-command/src/commands/headers.rs @@ -21,7 +21,7 @@ impl WholeStreamCommand for Headers { "Use the first row of the table as column names." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { headers(args) } @@ -41,7 +41,7 @@ impl WholeStreamCommand for Headers { } } -pub fn headers(args: CommandArgs) -> Result { +pub fn headers(args: CommandArgs) -> Result { let input = args.input; let rows: Vec = input.collect(); @@ -102,7 +102,7 @@ pub fn headers(args: CommandArgs) -> Result { )), } }) - .to_output_stream()) + .to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/help.rs b/crates/nu-command/src/commands/help.rs index e8eb4690f4b1..c1ff0248e35d 100644 --- a/crates/nu-command/src/commands/help.rs +++ b/crates/nu-command/src/commands/help.rs @@ -31,12 +31,12 @@ impl WholeStreamCommand for Help { "Display help information about commands." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { help(args) } } -fn help(args: CommandArgs) -> Result { +fn help(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let scope = args.scope.clone(); let (HelpArgs { rest }, ..) = args.process()?; @@ -154,24 +154,24 @@ fn help(args: CommandArgs) -> Result { ReturnSuccess::value(short_desc.into_value()) }); - Ok(iterator.to_output_stream()) + Ok(iterator.to_output_stream_with_actions()) } else if rest[0].item == "generate_docs" { - Ok(OutputStream::one(ReturnSuccess::value(generate_docs( + Ok(ActionStream::one(ReturnSuccess::value(generate_docs( &scope, )))) } else if rest.len() == 2 { // Check for a subcommand let command_name = format!("{} {}", rest[0].item, rest[1].item); if let Some(command) = scope.get_command(&command_name) { - Ok(OutputStream::one(ReturnSuccess::value( + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::string(get_full_help(command.stream_command(), &scope)) .into_value(Tag::unknown()), ))) } else { - Ok(OutputStream::empty()) + Ok(ActionStream::empty()) } } else if let Some(command) = scope.get_command(&rest[0].item) { - Ok(OutputStream::one(ReturnSuccess::value( + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::string(get_full_help(command.stream_command(), &scope)) .into_value(Tag::unknown()), ))) @@ -205,7 +205,7 @@ Get the processes on your system actively using CPU: You can also learn more at https://www.nushell.sh/book/"#; - Ok(OutputStream::one(ReturnSuccess::value( + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::string(msg).into_value(Tag::unknown()), ))) } diff --git a/crates/nu-command/src/commands/histogram.rs b/crates/nu-command/src/commands/histogram.rs index 536aa757f186..21e2c56541b5 100644 --- a/crates/nu-command/src/commands/histogram.rs +++ b/crates/nu-command/src/commands/histogram.rs @@ -31,7 +31,7 @@ impl WholeStreamCommand for Histogram { "Creates a new table with a histogram based on the column name passed in." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { histogram(args) } @@ -57,7 +57,7 @@ impl WholeStreamCommand for Histogram { } } -pub fn histogram(args: CommandArgs) -> Result { +pub fn histogram(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let (input, args) = args.evaluate_once()?.parts(); @@ -177,7 +177,7 @@ pub fn histogram(args: CommandArgs) -> Result { ReturnSuccess::value(fact.into_value()) }) - .to_output_stream()) + .to_output_stream_with_actions()) } fn evaluator(by: ColumnPath) -> Box Result + Send> { diff --git a/crates/nu-command/src/commands/history.rs b/crates/nu-command/src/commands/history.rs index 0a7c83f7f30a..76d6dc646df6 100644 --- a/crates/nu-command/src/commands/history.rs +++ b/crates/nu-command/src/commands/history.rs @@ -25,12 +25,12 @@ impl WholeStreamCommand for History { "Display command history." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { history(args) } } -fn history(args: CommandArgs) -> Result { +fn history(args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let ctx = EvaluationContext::from_args(&args); let (Arguments { clear }, _) = args.process()?; @@ -44,7 +44,7 @@ fn history(args: CommandArgs) -> Result { match clear { Some(_) => { // This is a NOOP, the logic to clear is handled in cli.rs - Ok(OutputStream::empty()) + Ok(ActionStream::empty()) } None => { if let Ok(file) = File::open(path) { @@ -57,7 +57,7 @@ fn history(args: CommandArgs) -> Result { Err(_) => None, }); - Ok(output.to_output_stream()) + Ok(output.to_output_stream_with_actions()) } else { Err(ShellError::labeled_error( "Could not open history", diff --git a/crates/nu-command/src/commands/if_.rs b/crates/nu-command/src/commands/if_.rs index 37f2f46ef7a7..7226dac411f8 100644 --- a/crates/nu-command/src/commands/if_.rs +++ b/crates/nu-command/src/commands/if_.rs @@ -6,6 +6,7 @@ use nu_errors::ShellError; use nu_protocol::{ hir::CapturedBlock, hir::ClassifiedCommand, Signature, SyntaxShape, UntaggedValue, }; +use nu_stream::OutputStream; pub struct If; @@ -110,11 +111,15 @@ fn if_command(raw_args: CommandArgs) -> Result { }; context.scope.exit_scope(); - result.map(|x| x.to_output_stream()) + result } - Err(e) => Ok(vec![Err(e)].into_iter().to_output_stream()), + Err(e) => Ok(OutputStream::from_stream( + vec![UntaggedValue::Error(e).into_untagged_value()].into_iter(), + )), }, - Err(e) => Ok(vec![Err(e)].into_iter().to_output_stream()), + Err(e) => Ok(OutputStream::from_stream( + vec![UntaggedValue::Error(e).into_untagged_value()].into_iter(), + )), } } diff --git a/crates/nu-command/src/commands/insert.rs b/crates/nu-command/src/commands/insert.rs index 0e02dc3e9e96..e86bfd4322eb 100644 --- a/crates/nu-command/src/commands/insert.rs +++ b/crates/nu-command/src/commands/insert.rs @@ -34,7 +34,7 @@ impl WholeStreamCommand for Command { "Insert a new column with a given value." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { insert(args) } @@ -66,7 +66,7 @@ fn process_row( input: Value, mut value: Arc, field: Arc, -) -> Result { +) -> Result { let value = Arc::make_mut(&mut value); Ok(match value { @@ -116,17 +116,17 @@ fn process_row( value: UntaggedValue::Row(_), .. } => match obj.insert_data_at_column_path(&field, result) { - Ok(v) => OutputStream::one(ReturnSuccess::value(v)), - Err(e) => OutputStream::one(Err(e)), + Ok(v) => ActionStream::one(ReturnSuccess::value(v)), + Err(e) => ActionStream::one(Err(e)), }, - _ => OutputStream::one(Err(ShellError::labeled_error( + _ => ActionStream::one(Err(ShellError::labeled_error( "Unrecognized type in stream", "original value", block_tag.clone(), ))), } } - Err(e) => OutputStream::one(Err(e)), + Err(e) => ActionStream::one(Err(e)), } } value => match input { @@ -139,18 +139,18 @@ fn process_row( .unwrap_or_else(|| UntaggedValue::nothing().into_untagged_value()) .insert_data_at_column_path(&field, value.clone()) { - Ok(v) => OutputStream::one(ReturnSuccess::value(v)), - Err(e) => OutputStream::one(Err(e)), + Ok(v) => ActionStream::one(ReturnSuccess::value(v)), + Err(e) => ActionStream::one(Err(e)), }, _ => match input.insert_data_at_column_path(&field, value.clone()) { - Ok(v) => OutputStream::one(ReturnSuccess::value(v)), - Err(e) => OutputStream::one(Err(e)), + Ok(v) => ActionStream::one(ReturnSuccess::value(v)), + Err(e) => ActionStream::one(Err(e)), }, }, }) } -fn insert(raw_args: CommandArgs) -> Result { +fn insert(raw_args: CommandArgs) -> Result { let context = Arc::new(EvaluationContext::from_args(&raw_args)); let (Arguments { column, value }, input) = raw_args.process()?; let value = Arc::new(value); @@ -164,9 +164,9 @@ fn insert(raw_args: CommandArgs) -> Result { match process_row(context, input, value, column) { Ok(s) => s, - Err(e) => OutputStream::one(Err(e)), + Err(e) => ActionStream::one(Err(e)), } }) .flatten() - .to_output_stream()) + .to_output_stream_with_actions()) } diff --git a/crates/nu-command/src/commands/into/command.rs b/crates/nu-command/src/commands/into/command.rs index ff916fc6c88c..b3373a34ed16 100644 --- a/crates/nu-command/src/commands/into/command.rs +++ b/crates/nu-command/src/commands/into/command.rs @@ -18,8 +18,8 @@ impl WholeStreamCommand for Command { "Apply into function." } - fn run(&self, args: CommandArgs) -> Result { - Ok(OutputStream::one(ReturnSuccess::value( + fn run_with_actions(&self, args: CommandArgs) -> Result { + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::string(get_full_help(&Command, &args.scope)).into_value(Tag::unknown()), ))) } diff --git a/crates/nu-command/src/commands/into/int.rs b/crates/nu-command/src/commands/into/int.rs index 255189a18022..c105478954f2 100644 --- a/crates/nu-command/src/commands/into/int.rs +++ b/crates/nu-command/src/commands/into/int.rs @@ -29,7 +29,7 @@ impl WholeStreamCommand for SubCommand { "Convert value to integer" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { into_int(args) } @@ -85,7 +85,7 @@ impl WholeStreamCommand for SubCommand { } } -fn into_int(args: CommandArgs) -> Result { +fn into_int(args: CommandArgs) -> Result { let (Arguments { rest: column_paths }, input) = args.process()?; Ok(input @@ -104,7 +104,7 @@ fn into_int(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } pub fn action(input: &Value, tag: impl Into) -> Result { diff --git a/crates/nu-command/src/commands/keep/command.rs b/crates/nu-command/src/commands/keep/command.rs index c3be7d7e9b32..52b0e649c453 100644 --- a/crates/nu-command/src/commands/keep/command.rs +++ b/crates/nu-command/src/commands/keep/command.rs @@ -28,7 +28,7 @@ impl WholeStreamCommand for Command { "Keep the number of rows only." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { keep(args) } @@ -53,7 +53,7 @@ impl WholeStreamCommand for Command { } } -fn keep(args: CommandArgs) -> Result { +fn keep(args: CommandArgs) -> Result { let (Arguments { rows }, input) = args.process()?; let rows_desired = if let Some(quantity) = rows { *quantity @@ -61,7 +61,7 @@ fn keep(args: CommandArgs) -> Result { 1 }; - Ok(input.take(rows_desired).to_output_stream()) + Ok(input.take(rows_desired).to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/keep/until.rs b/crates/nu-command/src/commands/keep/until.rs index a9b4caec0879..304d069e379c 100644 --- a/crates/nu-command/src/commands/keep/until.rs +++ b/crates/nu-command/src/commands/keep/until.rs @@ -27,7 +27,7 @@ impl WholeStreamCommand for SubCommand { "Keeps rows until the condition matches." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let ctx = Arc::new(EvaluationContext::from_args(&args)); let call_info = args.evaluate_once()?; @@ -93,7 +93,7 @@ impl WholeStreamCommand for SubCommand { !matches!(result, Ok(ref v) if v.is_true()) }) - .to_output_stream()) + .to_output_stream_with_actions()) } } diff --git a/crates/nu-command/src/commands/keep/while_.rs b/crates/nu-command/src/commands/keep/while_.rs index 5c1150bcddeb..175281eefe2f 100644 --- a/crates/nu-command/src/commands/keep/while_.rs +++ b/crates/nu-command/src/commands/keep/while_.rs @@ -26,7 +26,7 @@ impl WholeStreamCommand for SubCommand { "Keeps rows while the condition matches." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let ctx = Arc::new(EvaluationContext::from_args(&args)); let call_info = args.evaluate_once()?; @@ -92,7 +92,7 @@ impl WholeStreamCommand for SubCommand { matches!(result, Ok(ref v) if v.is_true()) }) - .to_output_stream()) + .to_output_stream_with_actions()) } } diff --git a/crates/nu-command/src/commands/kill.rs b/crates/nu-command/src/commands/kill.rs index 0d407b7aba79..779c5060de26 100644 --- a/crates/nu-command/src/commands/kill.rs +++ b/crates/nu-command/src/commands/kill.rs @@ -48,7 +48,7 @@ impl WholeStreamCommand for Kill { "Kill a process using the process id." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { kill(args) } @@ -73,7 +73,7 @@ impl WholeStreamCommand for Kill { } } -fn kill(args: CommandArgs) -> Result { +fn kill(args: CommandArgs) -> Result { let ( KillArgs { pid, @@ -136,7 +136,7 @@ fn kill(args: CommandArgs) -> Result { cmd.status().expect("failed to execute shell command"); - Ok(OutputStream::empty()) + Ok(ActionStream::empty()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/last.rs b/crates/nu-command/src/commands/last.rs index 47ab7a9b270a..628445ffb8f4 100644 --- a/crates/nu-command/src/commands/last.rs +++ b/crates/nu-command/src/commands/last.rs @@ -28,7 +28,7 @@ impl WholeStreamCommand for Last { "Show only the last number of rows." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { last(args) } @@ -52,7 +52,7 @@ impl WholeStreamCommand for Last { } } -fn last(args: CommandArgs) -> Result { +fn last(args: CommandArgs) -> Result { let (LastArgs { rows }, input) = args.process()?; let v: Vec<_> = input.into_vec(); @@ -70,7 +70,7 @@ fn last(args: CommandArgs) -> Result { let iter = v.into_iter().skip(beginning_rows_to_skip); - Ok((iter).to_output_stream()) + Ok((iter).to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/length.rs b/crates/nu-command/src/commands/length.rs index 67647f5f6af5..571bf897904d 100644 --- a/crates/nu-command/src/commands/length.rs +++ b/crates/nu-command/src/commands/length.rs @@ -28,7 +28,7 @@ impl WholeStreamCommand for Length { "Show the total number of rows or items." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let (LengthArgs { column }, input) = args.process()?; @@ -38,7 +38,7 @@ impl WholeStreamCommand for Length { done: false, tag, } - .to_output_stream()) + .to_output_stream_with_actions()) } fn examples(&self) -> Vec { diff --git a/crates/nu-command/src/commands/let_.rs b/crates/nu-command/src/commands/let_.rs index a5e4cc90daf9..2ad637250512 100644 --- a/crates/nu-command/src/commands/let_.rs +++ b/crates/nu-command/src/commands/let_.rs @@ -27,7 +27,7 @@ impl WholeStreamCommand for Let { "Create a variable and give it a value." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { letcmd(args) } @@ -36,7 +36,7 @@ impl WholeStreamCommand for Let { } } -pub fn letcmd(args: CommandArgs) -> Result { +pub fn letcmd(args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let ctx = EvaluationContext::from_args(&args); let args = args.evaluate_once()?; @@ -94,5 +94,5 @@ pub fn letcmd(args: CommandArgs) -> Result { // variable should be set into. ctx.scope.add_var(name, value); - Ok(OutputStream::empty()) + Ok(ActionStream::empty()) } diff --git a/crates/nu-command/src/commands/let_env.rs b/crates/nu-command/src/commands/let_env.rs index b4ab1f386903..1133d6ab198b 100644 --- a/crates/nu-command/src/commands/let_env.rs +++ b/crates/nu-command/src/commands/let_env.rs @@ -38,7 +38,7 @@ impl WholeStreamCommand for LetEnv { "Create an environment variable and give it a value." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { set_env(args) } @@ -47,7 +47,7 @@ impl WholeStreamCommand for LetEnv { } } -pub fn set_env(args: CommandArgs) -> Result { +pub fn set_env(args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let ctx = EvaluationContext::from_args(&args); @@ -99,5 +99,5 @@ pub fn set_env(args: CommandArgs) -> Result { // variable should be set into. ctx.scope.add_env_var(name, value); - Ok(OutputStream::empty()) + Ok(ActionStream::empty()) } diff --git a/crates/nu-command/src/commands/lines.rs b/crates/nu-command/src/commands/lines.rs index ee941e0b1519..5572a22e7bdb 100644 --- a/crates/nu-command/src/commands/lines.rs +++ b/crates/nu-command/src/commands/lines.rs @@ -19,7 +19,7 @@ impl WholeStreamCommand for Lines { "Split single string into rows, one per line." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { lines(args) } @@ -42,7 +42,7 @@ fn ends_with_line_ending(st: &str) -> bool { } } -fn lines(args: CommandArgs) -> Result { +fn lines(args: CommandArgs) -> Result { let leftover_string = Arc::new(Mutex::new(String::new())); let args = args.evaluate_once()?; let tag = args.name_tag(); @@ -113,7 +113,7 @@ fn lines(args: CommandArgs) -> Result { } }) .flatten() - .to_output_stream()) + .to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/ls.rs b/crates/nu-command/src/commands/ls.rs index 9b01b3b1d570..2f844a449a5e 100644 --- a/crates/nu-command/src/commands/ls.rs +++ b/crates/nu-command/src/commands/ls.rs @@ -39,7 +39,7 @@ impl WholeStreamCommand for Ls { "View the contents of the current or given path." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let ctrl_c = args.ctrl_c.clone(); let shell_manager = args.shell_manager.clone(); diff --git a/crates/nu-command/src/commands/macros.rs b/crates/nu-command/src/commands/macros.rs index e2e71fd501a3..7403b69215e0 100644 --- a/crates/nu-command/src/commands/macros.rs +++ b/crates/nu-command/src/commands/macros.rs @@ -33,7 +33,7 @@ macro_rules! command { fn command($args: EvaluatedCommandArgs, ( $($param_name),*, ): ( $($param_type),*, )) -> Result { let output = $body; - Ok(output.to_output_stream()) + Ok(output.to_output_stream_with_actions()) } let $args = $args.evaluate_once(registry)?; diff --git a/crates/nu-command/src/commands/math/abs.rs b/crates/nu-command/src/commands/math/abs.rs index 96ba2edfcda7..0ed327b26831 100644 --- a/crates/nu-command/src/commands/math/abs.rs +++ b/crates/nu-command/src/commands/math/abs.rs @@ -18,7 +18,7 @@ impl WholeStreamCommand for SubCommand { "Returns absolute values of a list of numbers" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let mapped = args.input.map(move |val| match val.value { UntaggedValue::Primitive(Primitive::Int(val)) => { UntaggedValue::int(val.magnitude().clone()).into() @@ -31,7 +31,7 @@ impl WholeStreamCommand for SubCommand { } other => abs_default(other), }); - Ok(OutputStream::from_input(mapped)) + Ok(ActionStream::from_input(mapped)) } fn examples(&self) -> Vec { diff --git a/crates/nu-command/src/commands/math/avg.rs b/crates/nu-command/src/commands/math/avg.rs index 13f7ccd74c29..84f46a8e4e56 100644 --- a/crates/nu-command/src/commands/math/avg.rs +++ b/crates/nu-command/src/commands/math/avg.rs @@ -27,7 +27,7 @@ impl WholeStreamCommand for SubCommand { "Finds the average of a list of numbers or tables" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { run_with_function(args, average) } diff --git a/crates/nu-command/src/commands/math/ceil.rs b/crates/nu-command/src/commands/math/ceil.rs index c981592a5011..7b103870407c 100644 --- a/crates/nu-command/src/commands/math/ceil.rs +++ b/crates/nu-command/src/commands/math/ceil.rs @@ -20,7 +20,7 @@ impl WholeStreamCommand for SubCommand { "Applies the ceil function to a list of numbers" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let input = args.input; run_with_numerical_functions_on_stream(input, ceil_big_int, ceil_big_decimal, ceil_default) diff --git a/crates/nu-command/src/commands/math/command.rs b/crates/nu-command/src/commands/math/command.rs index 718ae4d87a60..6b8f546fca64 100644 --- a/crates/nu-command/src/commands/math/command.rs +++ b/crates/nu-command/src/commands/math/command.rs @@ -18,8 +18,8 @@ impl WholeStreamCommand for Command { "Use mathematical functions as aggregate functions on a list of numbers or tables." } - fn run(&self, args: CommandArgs) -> Result { - Ok(OutputStream::one(Ok(ReturnSuccess::Value( + fn run_with_actions(&self, args: CommandArgs) -> Result { + Ok(ActionStream::one(Ok(ReturnSuccess::Value( UntaggedValue::string(get_full_help(&Command, &args.scope)).into_value(Tag::unknown()), )))) } diff --git a/crates/nu-command/src/commands/math/eval.rs b/crates/nu-command/src/commands/math/eval.rs index ee4239682eb6..7dc61f60301a 100644 --- a/crates/nu-command/src/commands/math/eval.rs +++ b/crates/nu-command/src/commands/math/eval.rs @@ -28,7 +28,7 @@ impl WholeStreamCommand for SubCommand { ) } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { eval(args) } @@ -45,13 +45,13 @@ impl WholeStreamCommand for SubCommand { } } -pub fn eval(args: CommandArgs) -> Result { +pub fn eval(args: CommandArgs) -> Result { let name = args.call_info.name_tag.span; let (SubCommandArgs { expression }, input) = args.process()?; if let Some(string) = expression { match parse(&string, &string.tag) { - Ok(value) => Ok(OutputStream::one(ReturnSuccess::value(value))), + Ok(value) => Ok(ActionStream::one(ReturnSuccess::value(value))), Err(err) => Err(ShellError::labeled_error( "Math evaluation error", err, @@ -89,7 +89,7 @@ pub fn eval(args: CommandArgs) -> Result { )) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } } diff --git a/crates/nu-command/src/commands/math/floor.rs b/crates/nu-command/src/commands/math/floor.rs index d5da9f6a05ce..1fa82dd6e151 100644 --- a/crates/nu-command/src/commands/math/floor.rs +++ b/crates/nu-command/src/commands/math/floor.rs @@ -20,7 +20,7 @@ impl WholeStreamCommand for SubCommand { "Applies the floor function to a list of numbers" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let input = args.input; run_with_numerical_functions_on_stream( diff --git a/crates/nu-command/src/commands/math/max.rs b/crates/nu-command/src/commands/math/max.rs index 0facfafcc093..9cd9ca36202d 100644 --- a/crates/nu-command/src/commands/math/max.rs +++ b/crates/nu-command/src/commands/math/max.rs @@ -20,7 +20,7 @@ impl WholeStreamCommand for SubCommand { "Finds the maximum within a list of numbers or tables" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { run_with_function(args, maximum) } diff --git a/crates/nu-command/src/commands/math/median.rs b/crates/nu-command/src/commands/math/median.rs index de7a4a9b7656..519bdc0ff422 100644 --- a/crates/nu-command/src/commands/math/median.rs +++ b/crates/nu-command/src/commands/math/median.rs @@ -24,7 +24,7 @@ impl WholeStreamCommand for SubCommand { "Gets the median of a list of numbers" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { run_with_function(args, median) } diff --git a/crates/nu-command/src/commands/math/min.rs b/crates/nu-command/src/commands/math/min.rs index 2ed64a0c4411..c747700adf01 100644 --- a/crates/nu-command/src/commands/math/min.rs +++ b/crates/nu-command/src/commands/math/min.rs @@ -20,7 +20,7 @@ impl WholeStreamCommand for SubCommand { "Finds the minimum within a list of numbers or tables" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { run_with_function(args, minimum) } diff --git a/crates/nu-command/src/commands/math/mode.rs b/crates/nu-command/src/commands/math/mode.rs index 112808ebf2e5..932e6ed2024e 100644 --- a/crates/nu-command/src/commands/math/mode.rs +++ b/crates/nu-command/src/commands/math/mode.rs @@ -20,7 +20,7 @@ impl WholeStreamCommand for SubCommand { "Gets the most frequent element(s) from a list of numbers or tables" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { run_with_function(args, mode) } diff --git a/crates/nu-command/src/commands/math/product.rs b/crates/nu-command/src/commands/math/product.rs index 62decd9ba415..8c36f38b4905 100644 --- a/crates/nu-command/src/commands/math/product.rs +++ b/crates/nu-command/src/commands/math/product.rs @@ -20,7 +20,7 @@ impl WholeStreamCommand for SubCommand { "Finds the product of a list of numbers or tables" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { run_with_function(args, product) } diff --git a/crates/nu-command/src/commands/math/round.rs b/crates/nu-command/src/commands/math/round.rs index a239af15b0da..60910b77eb54 100644 --- a/crates/nu-command/src/commands/math/round.rs +++ b/crates/nu-command/src/commands/math/round.rs @@ -29,7 +29,7 @@ impl WholeStreamCommand for SubCommand { "Applies the round function to a list of numbers" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args) } @@ -57,7 +57,7 @@ impl WholeStreamCommand for SubCommand { } } -fn operate(args: CommandArgs) -> Result { +fn operate(args: CommandArgs) -> Result { let (Arguments { precision }, input) = args.process()?; let precision = precision.map(|p| p.item).unwrap_or(0); @@ -66,7 +66,7 @@ fn operate(args: CommandArgs) -> Result { UntaggedValue::Primitive(Primitive::Decimal(val)) => round_big_decimal(val, precision), other => round_default(other), }); - Ok(OutputStream::from_input(mapped)) + Ok(ActionStream::from_input(mapped)) } fn round_big_int(val: BigInt) -> Value { diff --git a/crates/nu-command/src/commands/math/sqrt.rs b/crates/nu-command/src/commands/math/sqrt.rs index 4f446b18f831..a02ba1647d25 100644 --- a/crates/nu-command/src/commands/math/sqrt.rs +++ b/crates/nu-command/src/commands/math/sqrt.rs @@ -18,7 +18,7 @@ impl WholeStreamCommand for SubCommand { "Applies the square root function to a list of numbers" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { Ok(operate(args)) } @@ -34,13 +34,13 @@ impl WholeStreamCommand for SubCommand { } } -fn operate(args: CommandArgs) -> OutputStream { +fn operate(args: CommandArgs) -> ActionStream { let mapped = args.input.map(move |val| match val.value { UntaggedValue::Primitive(Primitive::Int(val)) => sqrt_big_decimal(BigDecimal::from(val)), UntaggedValue::Primitive(Primitive::Decimal(val)) => sqrt_big_decimal(val), other => sqrt_default(other), }); - OutputStream::from_input(mapped) + ActionStream::from_input(mapped) } fn sqrt_big_decimal(val: BigDecimal) -> Value { diff --git a/crates/nu-command/src/commands/math/stddev.rs b/crates/nu-command/src/commands/math/stddev.rs index 6f1723cdfb17..3ad5e0598972 100644 --- a/crates/nu-command/src/commands/math/stddev.rs +++ b/crates/nu-command/src/commands/math/stddev.rs @@ -30,7 +30,7 @@ impl WholeStreamCommand for SubCommand { "Finds the stddev of a list of numbers or tables" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let (Arguments { sample }, mut input) = args.process()?; @@ -81,13 +81,13 @@ impl WholeStreamCommand for SubCommand { }?; if res.value.is_table() { - Ok(OutputStream::from( + Ok(ActionStream::from( res.table_entries() .map(|v| ReturnSuccess::value(v.clone())) .collect::>(), )) } else { - Ok(OutputStream::one(ReturnSuccess::value(res))) + Ok(ActionStream::one(ReturnSuccess::value(res))) } } diff --git a/crates/nu-command/src/commands/math/sum.rs b/crates/nu-command/src/commands/math/sum.rs index 0f09a1983114..224685e3c07d 100644 --- a/crates/nu-command/src/commands/math/sum.rs +++ b/crates/nu-command/src/commands/math/sum.rs @@ -21,7 +21,7 @@ impl WholeStreamCommand for SubCommand { "Finds the sum of a list of numbers or tables" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { run_with_function(args, summation) } diff --git a/crates/nu-command/src/commands/math/utils.rs b/crates/nu-command/src/commands/math/utils.rs index e9108d587865..fb4cd5d2d5e4 100644 --- a/crates/nu-command/src/commands/math/utils.rs +++ b/crates/nu-command/src/commands/math/utils.rs @@ -9,7 +9,7 @@ pub type MathFunction = fn(values: &[Value], tag: &Tag) -> Result, mf: MathFunction, -) -> Result { +) -> Result { let RunnableContext { mut input, call_info, @@ -23,13 +23,13 @@ pub fn run_with_function( match res { Ok(v) => { if v.value.is_table() { - Ok(OutputStream::from( + Ok(ActionStream::from( v.table_entries() .map(|v| ReturnSuccess::value(v.clone())) .collect::>(), )) } else { - Ok(OutputStream::one(ReturnSuccess::value(v))) + Ok(ActionStream::one(ReturnSuccess::value(v))) } } Err(e) => Err(e), @@ -47,13 +47,13 @@ pub fn run_with_numerical_functions_on_stream( int_function: IntFunction, decimal_function: DecimalFunction, default_function: DefaultFunction, -) -> Result { +) -> Result { let mapped = input.map(move |val| match val.value { UntaggedValue::Primitive(Primitive::Int(val)) => int_function(val), UntaggedValue::Primitive(Primitive::Decimal(val)) => decimal_function(val), other => default_function(other), }); - Ok(OutputStream::from_input(mapped)) + Ok(ActionStream::from_input(mapped)) } pub fn calculate(values: &[Value], name: &Tag, mf: MathFunction) -> Result { diff --git a/crates/nu-command/src/commands/math/variance.rs b/crates/nu-command/src/commands/math/variance.rs index 55e6cba00d2f..dc06e646d697 100644 --- a/crates/nu-command/src/commands/math/variance.rs +++ b/crates/nu-command/src/commands/math/variance.rs @@ -28,7 +28,7 @@ impl WholeStreamCommand for SubCommand { "Finds the variance of a list of numbers or tables" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let (Arguments { sample }, mut input) = args.process()?; @@ -79,13 +79,13 @@ impl WholeStreamCommand for SubCommand { }?; if res.value.is_table() { - Ok(OutputStream::from( + Ok(ActionStream::from( res.table_entries() .map(|v| ReturnSuccess::value(v.clone())) .collect::>(), )) } else { - Ok(OutputStream::one(ReturnSuccess::value(res))) + Ok(ActionStream::one(ReturnSuccess::value(res))) } } diff --git a/crates/nu-command/src/commands/merge.rs b/crates/nu-command/src/commands/merge.rs index ad150f9d2254..644d9a35b9ea 100644 --- a/crates/nu-command/src/commands/merge.rs +++ b/crates/nu-command/src/commands/merge.rs @@ -32,7 +32,7 @@ impl WholeStreamCommand for Merge { "Merge a table." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { merge(args) } @@ -45,7 +45,7 @@ impl WholeStreamCommand for Merge { } } -fn merge(raw_args: CommandArgs) -> Result { +fn merge(raw_args: CommandArgs) -> Result { let context = EvaluationContext::from_args(&raw_args); let name_tag = raw_args.call_info.name_tag.clone(); let (merge_args, input): (MergeArgs, _) = raw_args.process()?; @@ -90,7 +90,7 @@ fn merge(raw_args: CommandArgs) -> Result { None => ReturnSuccess::value(value), } }) - .to_output_stream()) + .to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/mkdir.rs b/crates/nu-command/src/commands/mkdir.rs index a58f0ff3433a..96167ce0eeb5 100644 --- a/crates/nu-command/src/commands/mkdir.rs +++ b/crates/nu-command/src/commands/mkdir.rs @@ -22,7 +22,7 @@ impl WholeStreamCommand for Mkdir { "Make directories, creates intermediary directories as required." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { mkdir(args) } @@ -35,7 +35,7 @@ impl WholeStreamCommand for Mkdir { } } -fn mkdir(args: CommandArgs) -> Result { +fn mkdir(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let shell_manager = args.shell_manager.clone(); let (args, _) = args.process()?; diff --git a/crates/nu-command/src/commands/move_/command.rs b/crates/nu-command/src/commands/move_/command.rs index 320cd6483af1..24fdfdfdf430 100644 --- a/crates/nu-command/src/commands/move_/command.rs +++ b/crates/nu-command/src/commands/move_/command.rs @@ -40,7 +40,7 @@ impl WholeStreamCommand for Command { "Move columns." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args) } @@ -82,7 +82,7 @@ impl WholeStreamCommand for Command { } } -fn operate(raw_args: CommandArgs) -> Result { +fn operate(raw_args: CommandArgs) -> Result { let name = raw_args.call_info.name_tag.clone(); let ( Arguments { @@ -169,7 +169,7 @@ fn operate(raw_args: CommandArgs) -> Result { )) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } else if let Some(before) = before { let member = columns.remove(0); @@ -217,7 +217,7 @@ fn operate(raw_args: CommandArgs) -> Result { )) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } else { Err(ShellError::labeled_error( "no columns given", diff --git a/crates/nu-command/src/commands/move_/mv.rs b/crates/nu-command/src/commands/move_/mv.rs index 12c6974408af..17adc9f36086 100644 --- a/crates/nu-command/src/commands/move_/mv.rs +++ b/crates/nu-command/src/commands/move_/mv.rs @@ -28,7 +28,7 @@ impl WholeStreamCommand for Mv { "Move files or directories." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { mv(args) } @@ -53,7 +53,7 @@ impl WholeStreamCommand for Mv { } } -fn mv(args: CommandArgs) -> Result { +fn mv(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let shell_manager = args.shell_manager.clone(); let (args, _) = args.process()?; diff --git a/crates/nu-command/src/commands/next.rs b/crates/nu-command/src/commands/next.rs index 9c74b8647bb3..73df6aaa24b8 100644 --- a/crates/nu-command/src/commands/next.rs +++ b/crates/nu-command/src/commands/next.rs @@ -18,12 +18,12 @@ impl WholeStreamCommand for Next { "Go to next shell." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { Ok(next(args)) } } -fn next(_args: CommandArgs) -> OutputStream { +fn next(_args: CommandArgs) -> ActionStream { vec![Ok(ReturnSuccess::Action(CommandAction::NextShell))].into() } diff --git a/crates/nu-command/src/commands/nth.rs b/crates/nu-command/src/commands/nth.rs index 4df6a701fb33..aa0f99bb29ac 100644 --- a/crates/nu-command/src/commands/nth.rs +++ b/crates/nu-command/src/commands/nth.rs @@ -33,7 +33,7 @@ impl WholeStreamCommand for Nth { "Return or skip only the selected rows." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { nth(args) } @@ -58,7 +58,7 @@ impl WholeStreamCommand for Nth { } } -fn nth(args: CommandArgs) -> Result { +fn nth(args: CommandArgs) -> Result { let ( NthArgs { row_number, @@ -83,7 +83,7 @@ fn nth(args: CommandArgs) -> Result { None } }) - .to_output_stream()) + .to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/nu/plugin.rs b/crates/nu-command/src/commands/nu/plugin.rs index 3a69b037dbf3..f74a3e4e4fd5 100644 --- a/crates/nu-command/src/commands/nu/plugin.rs +++ b/crates/nu-command/src/commands/nu/plugin.rs @@ -45,7 +45,7 @@ impl WholeStreamCommand for SubCommand { }] } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let scope = args.scope.clone(); let shell_manager = args.shell_manager.clone(); let (Arguments { load_path }, _) = args.process()?; @@ -99,7 +99,7 @@ impl WholeStreamCommand for SubCommand { .into()); } - Ok(OutputStream::one(ReturnSuccess::value( + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::string(get_full_help(&SubCommand, &scope)).into_value(Tag::unknown()), ))) } diff --git a/crates/nu-command/src/commands/open.rs b/crates/nu-command/src/commands/open.rs index b08e74e6f000..55d7e17b2277 100644 --- a/crates/nu-command/src/commands/open.rs +++ b/crates/nu-command/src/commands/open.rs @@ -57,7 +57,7 @@ For a more complete list of encodings please refer to the encoding_rs documentation link at https://docs.rs/encoding_rs/0.8.28/encoding_rs/#statics"# } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { open(args) } @@ -99,7 +99,7 @@ pub fn get_encoding(opt: Option>) -> Result<&'static Encoding, Sh } } -fn open(args: CommandArgs) -> Result { +fn open(args: CommandArgs) -> Result { let scope = args.scope.clone(); let cwd = PathBuf::from(args.shell_manager.path()); let shell_manager = args.shell_manager.clone(); @@ -148,7 +148,7 @@ fn open(args: CommandArgs) -> Result { path.tag.span, encoding, )?; - return Ok(OutputStream::one(ReturnSuccess::action( + return Ok(ActionStream::one(ReturnSuccess::action( CommandAction::AutoConvert(tagged_contents, ext), ))); } @@ -160,7 +160,7 @@ fn open(args: CommandArgs) -> Result { path.tag.span, encoding, )?; - return Ok(OutputStream::one(ReturnSuccess::value(tagged_contents))); + return Ok(ActionStream::one(ReturnSuccess::value(tagged_contents))); } } @@ -191,7 +191,7 @@ fn open(args: CommandArgs) -> Result { } }); - Ok(OutputStream::new(final_stream)) + Ok(ActionStream::new(final_stream)) } // Note that we do not output a Stream in "fetch" since it is only used by "enter" command diff --git a/crates/nu-command/src/commands/parse/command.rs b/crates/nu-command/src/commands/parse/command.rs index 4b0fd1713421..40bca4af83bc 100644 --- a/crates/nu-command/src/commands/parse/command.rs +++ b/crates/nu-command/src/commands/parse/command.rs @@ -33,7 +33,7 @@ impl WholeStreamCommand for Command { "Parse columns from string data using a simple pattern." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args) } @@ -49,7 +49,7 @@ impl WholeStreamCommand for Command { } } -pub fn operate(args: CommandArgs) -> Result { +pub fn operate(args: CommandArgs) -> Result { let name_tag = args.call_info.name_tag.clone(); let (Arguments { regex, pattern }, input) = args.process()?; @@ -95,7 +95,7 @@ pub fn operate(args: CommandArgs) -> Result { } } - Ok(parsed.into_iter().to_output_stream()) + Ok(parsed.into_iter().to_output_stream_with_actions()) } fn build_regex(input: &str, tag: Tag) -> Result { diff --git a/crates/nu-command/src/commands/path/basename.rs b/crates/nu-command/src/commands/path/basename.rs index 6141b55653d2..47e02bdd863b 100644 --- a/crates/nu-command/src/commands/path/basename.rs +++ b/crates/nu-command/src/commands/path/basename.rs @@ -40,7 +40,7 @@ impl WholeStreamCommand for PathBasename { "Gets the final component of a path" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let (PathBasenameArguments { replace, rest }, input) = args.process()?; let args = Arc::new(PathBasenameArguments { replace, rest }); diff --git a/crates/nu-command/src/commands/path/command.rs b/crates/nu-command/src/commands/path/command.rs index 6f07b799c36b..53d144829845 100644 --- a/crates/nu-command/src/commands/path/command.rs +++ b/crates/nu-command/src/commands/path/command.rs @@ -18,8 +18,8 @@ impl WholeStreamCommand for Path { "Explore and manipulate paths." } - fn run(&self, args: CommandArgs) -> Result { - Ok(OutputStream::one(ReturnSuccess::value( + fn run_with_actions(&self, args: CommandArgs) -> Result { + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::string(get_full_help(&Path, &args.scope)).into_value(Tag::unknown()), ))) } diff --git a/crates/nu-command/src/commands/path/dirname.rs b/crates/nu-command/src/commands/path/dirname.rs index 8faa973557ce..d5d05fe2490e 100644 --- a/crates/nu-command/src/commands/path/dirname.rs +++ b/crates/nu-command/src/commands/path/dirname.rs @@ -48,7 +48,7 @@ impl WholeStreamCommand for PathDirname { "Gets the parent directory of a path" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let ( PathDirnameArguments { diff --git a/crates/nu-command/src/commands/path/exists.rs b/crates/nu-command/src/commands/path/exists.rs index fb6b2d15f62d..b8e49e9c794a 100644 --- a/crates/nu-command/src/commands/path/exists.rs +++ b/crates/nu-command/src/commands/path/exists.rs @@ -32,7 +32,7 @@ impl WholeStreamCommand for PathExists { "Checks whether a path exists" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let (PathExistsArguments { rest }, input) = args.process()?; let args = Arc::new(PathExistsArguments { rest }); diff --git a/crates/nu-command/src/commands/path/expand.rs b/crates/nu-command/src/commands/path/expand.rs index dab862afe44d..1f9d35de234f 100644 --- a/crates/nu-command/src/commands/path/expand.rs +++ b/crates/nu-command/src/commands/path/expand.rs @@ -32,7 +32,7 @@ impl WholeStreamCommand for PathExpand { "Expands a path to its absolute form" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let (PathExpandArguments { rest }, input) = args.process()?; let args = Arc::new(PathExpandArguments { rest }); diff --git a/crates/nu-command/src/commands/path/extension.rs b/crates/nu-command/src/commands/path/extension.rs index 69643fc61222..397069244322 100644 --- a/crates/nu-command/src/commands/path/extension.rs +++ b/crates/nu-command/src/commands/path/extension.rs @@ -40,7 +40,7 @@ impl WholeStreamCommand for PathExtension { "Gets the extension of a path" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let (PathExtensionArguments { replace, rest }, input) = args.process()?; let args = Arc::new(PathExtensionArguments { replace, rest }); diff --git a/crates/nu-command/src/commands/path/filestem.rs b/crates/nu-command/src/commands/path/filestem.rs index 40ebc8cda4ff..f62d1d8d630a 100644 --- a/crates/nu-command/src/commands/path/filestem.rs +++ b/crates/nu-command/src/commands/path/filestem.rs @@ -54,7 +54,7 @@ impl WholeStreamCommand for PathFilestem { "Gets the file stem of a path" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let ( PathFilestemArguments { diff --git a/crates/nu-command/src/commands/path/join.rs b/crates/nu-command/src/commands/path/join.rs index aff34843ecd4..a2322ae75927 100644 --- a/crates/nu-command/src/commands/path/join.rs +++ b/crates/nu-command/src/commands/path/join.rs @@ -35,7 +35,7 @@ impl WholeStreamCommand for PathJoin { "Joins an input path with another path" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let (PathJoinArguments { path, rest }, input) = args.process()?; let args = Arc::new(PathJoinArguments { path, rest }); diff --git a/crates/nu-command/src/commands/path/mod.rs b/crates/nu-command/src/commands/path/mod.rs index 037d218c2261..4daeeebba7c2 100644 --- a/crates/nu-command/src/commands/path/mod.rs +++ b/crates/nu-command/src/commands/path/mod.rs @@ -60,7 +60,7 @@ fn operate( action: &'static F, span: Span, args: Arc, -) -> OutputStream +) -> ActionStream where T: PathSubcommandArguments + Send + Sync + 'static, F: Fn(&Path, &T) -> UntaggedValue + Send + Sync + 'static, @@ -83,5 +83,5 @@ where ReturnSuccess::value(ret) } }) - .to_output_stream() + .to_output_stream_with_actions() } diff --git a/crates/nu-command/src/commands/path/type.rs b/crates/nu-command/src/commands/path/type.rs index 197832531a2d..3f481ecbc375 100644 --- a/crates/nu-command/src/commands/path/type.rs +++ b/crates/nu-command/src/commands/path/type.rs @@ -33,7 +33,7 @@ impl WholeStreamCommand for PathType { "Gives the type of the object a path refers to (e.g., file, dir, symlink)" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let (PathTypeArguments { rest }, input) = args.process()?; let args = Arc::new(PathTypeArguments { rest }); diff --git a/crates/nu-command/src/commands/pivot.rs b/crates/nu-command/src/commands/pivot.rs index 581cd9c8c958..4939e29e9521 100644 --- a/crates/nu-command/src/commands/pivot.rs +++ b/crates/nu-command/src/commands/pivot.rs @@ -45,12 +45,12 @@ impl WholeStreamCommand for Pivot { "Pivots the table contents so rows become columns and columns become rows." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { pivot(args) } } -pub fn pivot(args: CommandArgs) -> Result { +pub fn pivot(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let (args, input): (PivotArgs, _) = args.process()?; let input = input.into_vec(); @@ -140,7 +140,7 @@ pub fn pivot(args: CommandArgs) -> Result { ReturnSuccess::value(dict.into_value()) })) - .to_output_stream()) + .to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/prepend.rs b/crates/nu-command/src/commands/prepend.rs index d4f8eacb25fb..f375cb8dcc02 100644 --- a/crates/nu-command/src/commands/prepend.rs +++ b/crates/nu-command/src/commands/prepend.rs @@ -27,7 +27,7 @@ impl WholeStreamCommand for Prepend { "Prepend the given row to the front of the table." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { prepend(args) } @@ -45,12 +45,12 @@ impl WholeStreamCommand for Prepend { } } -fn prepend(args: CommandArgs) -> Result { +fn prepend(args: CommandArgs) -> Result { let (PrependArgs { row }, input) = args.process()?; let bos = vec![row].into_iter(); - Ok(bos.chain(input).to_output_stream()) + Ok(bos.chain(input).to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/prev.rs b/crates/nu-command/src/commands/prev.rs index d5eb23b766a0..d32a904228cb 100644 --- a/crates/nu-command/src/commands/prev.rs +++ b/crates/nu-command/src/commands/prev.rs @@ -19,12 +19,12 @@ impl WholeStreamCommand for Previous { "Go to previous shell." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { Ok(previous(args)) } } -fn previous(_args: CommandArgs) -> OutputStream { +fn previous(_args: CommandArgs) -> ActionStream { vec![Ok(ReturnSuccess::Action(CommandAction::PreviousShell))].into() } diff --git a/crates/nu-command/src/commands/pwd.rs b/crates/nu-command/src/commands/pwd.rs index cfecb0ed34b2..f71e3f1cdf4e 100644 --- a/crates/nu-command/src/commands/pwd.rs +++ b/crates/nu-command/src/commands/pwd.rs @@ -18,7 +18,7 @@ impl WholeStreamCommand for Pwd { "Output the current working directory." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { pwd(args) } @@ -31,7 +31,7 @@ impl WholeStreamCommand for Pwd { } } -pub fn pwd(args: CommandArgs) -> Result { +pub fn pwd(args: CommandArgs) -> Result { let shell_manager = args.shell_manager.clone(); let args = args.evaluate_once()?; diff --git a/crates/nu-command/src/commands/random/bool.rs b/crates/nu-command/src/commands/random/bool.rs index 24e2e129bd25..e6be775c6321 100644 --- a/crates/nu-command/src/commands/random/bool.rs +++ b/crates/nu-command/src/commands/random/bool.rs @@ -30,7 +30,7 @@ impl WholeStreamCommand for SubCommand { "Generate a random boolean value" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { bool_command(args) } @@ -50,7 +50,7 @@ impl WholeStreamCommand for SubCommand { } } -pub fn bool_command(args: CommandArgs) -> Result { +pub fn bool_command(args: CommandArgs) -> Result { let (BoolArgs { bias }, _) = args.process()?; let mut probability = 0.5; @@ -73,7 +73,7 @@ pub fn bool_command(args: CommandArgs) -> Result { let bool_result: bool = rng.gen_bool(probability); let bool_untagged_value = UntaggedValue::boolean(bool_result); - Ok(OutputStream::one(ReturnSuccess::value(bool_untagged_value))) + Ok(ActionStream::one(ReturnSuccess::value(bool_untagged_value))) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/random/chars.rs b/crates/nu-command/src/commands/random/chars.rs index a4b63a43796e..f7541a7a33c3 100644 --- a/crates/nu-command/src/commands/random/chars.rs +++ b/crates/nu-command/src/commands/random/chars.rs @@ -33,7 +33,7 @@ impl WholeStreamCommand for SubCommand { "Generate random chars" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { chars(args) } @@ -53,7 +53,7 @@ impl WholeStreamCommand for SubCommand { } } -pub fn chars(args: CommandArgs) -> Result { +pub fn chars(args: CommandArgs) -> Result { let (CharsArgs { length }, _) = args.process()?; let chars_length = length.map_or(DEFAULT_CHARS_LENGTH, |l| l.item); @@ -64,7 +64,7 @@ pub fn chars(args: CommandArgs) -> Result { .collect(); let result = UntaggedValue::string(random_string); - Ok(OutputStream::one(ReturnSuccess::value(result))) + Ok(ActionStream::one(ReturnSuccess::value(result))) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/random/command.rs b/crates/nu-command/src/commands/random/command.rs index f57b15568c03..9072fec370b1 100644 --- a/crates/nu-command/src/commands/random/command.rs +++ b/crates/nu-command/src/commands/random/command.rs @@ -18,8 +18,8 @@ impl WholeStreamCommand for Command { "Generate random values." } - fn run(&self, args: CommandArgs) -> Result { - Ok(OutputStream::one(Ok(ReturnSuccess::Value( + fn run_with_actions(&self, args: CommandArgs) -> Result { + Ok(ActionStream::one(Ok(ReturnSuccess::Value( UntaggedValue::string(get_full_help(&Command, &args.scope)).into_value(Tag::unknown()), )))) } diff --git a/crates/nu-command/src/commands/random/decimal.rs b/crates/nu-command/src/commands/random/decimal.rs index f695d15ef1f5..18951180e955 100644 --- a/crates/nu-command/src/commands/random/decimal.rs +++ b/crates/nu-command/src/commands/random/decimal.rs @@ -27,7 +27,7 @@ impl WholeStreamCommand for SubCommand { "Generate a random decimal within a range [min..max]" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { decimal(args) } @@ -57,7 +57,7 @@ impl WholeStreamCommand for SubCommand { } } -pub fn decimal(args: CommandArgs) -> Result { +pub fn decimal(args: CommandArgs) -> Result { let (DecimalArgs { range }, _) = args.process()?; let (min, max) = if let Some(range) = &range { @@ -76,7 +76,7 @@ pub fn decimal(args: CommandArgs) -> Result { )), Some(Ordering::Equal) => { let untagged_result = UntaggedValue::decimal_from_float(min, Span::new(64, 64)); - Ok(OutputStream::one(ReturnSuccess::value(untagged_result))) + Ok(ActionStream::one(ReturnSuccess::value(untagged_result))) } _ => { let mut thread_rng = thread_rng(); @@ -84,7 +84,7 @@ pub fn decimal(args: CommandArgs) -> Result { let untagged_result = UntaggedValue::decimal_from_float(result, Span::new(64, 64)); - Ok(OutputStream::one(ReturnSuccess::value(untagged_result))) + Ok(ActionStream::one(ReturnSuccess::value(untagged_result))) } } } diff --git a/crates/nu-command/src/commands/random/dice.rs b/crates/nu-command/src/commands/random/dice.rs index d34446967a54..d93d5e833bd1 100644 --- a/crates/nu-command/src/commands/random/dice.rs +++ b/crates/nu-command/src/commands/random/dice.rs @@ -38,7 +38,7 @@ impl WholeStreamCommand for SubCommand { "Generate a random dice roll" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { dice(args) } @@ -58,7 +58,7 @@ impl WholeStreamCommand for SubCommand { } } -pub fn dice(args: CommandArgs) -> Result { +pub fn dice(args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let (DiceArgs { dice, sides }, _) = args.process()?; @@ -79,7 +79,7 @@ pub fn dice(args: CommandArgs) -> Result { UntaggedValue::int(thread_rng.gen_range(1, sides + 1)).into_value(tag.clone()) }); - Ok((iter).to_output_stream()) + Ok((iter).to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/random/integer.rs b/crates/nu-command/src/commands/random/integer.rs index 18a9a69d97d3..94184d2bae8c 100644 --- a/crates/nu-command/src/commands/random/integer.rs +++ b/crates/nu-command/src/commands/random/integer.rs @@ -27,7 +27,7 @@ impl WholeStreamCommand for SubCommand { "Generate a random integer [min..max]" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { integer(args) } @@ -57,7 +57,7 @@ impl WholeStreamCommand for SubCommand { } } -pub fn integer(args: CommandArgs) -> Result { +pub fn integer(args: CommandArgs) -> Result { let (IntegerArgs { range }, _) = args.process()?; let (min, max) = if let Some(range) = &range { @@ -76,7 +76,7 @@ pub fn integer(args: CommandArgs) -> Result { )), Ordering::Equal => { let untagged_result = UntaggedValue::int(min).into_value(Tag::unknown()); - Ok(OutputStream::one(ReturnSuccess::value(untagged_result))) + Ok(ActionStream::one(ReturnSuccess::value(untagged_result))) } _ => { let mut thread_rng = thread_rng(); @@ -86,7 +86,7 @@ pub fn integer(args: CommandArgs) -> Result { let untagged_result = UntaggedValue::int(result).into_value(Tag::unknown()); - Ok(OutputStream::one(ReturnSuccess::value(untagged_result))) + Ok(ActionStream::one(ReturnSuccess::value(untagged_result))) } } } diff --git a/crates/nu-command/src/commands/random/uuid.rs b/crates/nu-command/src/commands/random/uuid.rs index ad2f38e17298..bccfdd84c7d1 100644 --- a/crates/nu-command/src/commands/random/uuid.rs +++ b/crates/nu-command/src/commands/random/uuid.rs @@ -19,7 +19,7 @@ impl WholeStreamCommand for SubCommand { "Generate a random uuid4 string" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { uuid(args) } @@ -32,10 +32,10 @@ impl WholeStreamCommand for SubCommand { } } -pub fn uuid(_args: CommandArgs) -> Result { +pub fn uuid(_args: CommandArgs) -> Result { let uuid_4 = Uuid::new_v4().to_hyphenated().to_string(); - Ok(OutputStream::one(ReturnSuccess::value(uuid_4))) + Ok(ActionStream::one(ReturnSuccess::value(uuid_4))) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/range.rs b/crates/nu-command/src/commands/range.rs index e4ee5e9d441d..4bcf5e3e3bd4 100644 --- a/crates/nu-command/src/commands/range.rs +++ b/crates/nu-command/src/commands/range.rs @@ -29,12 +29,12 @@ impl WholeStreamCommand for Range { "Return only the selected rows." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { range(args) } } -fn range(args: CommandArgs) -> Result { +fn range(args: CommandArgs) -> Result { let (RangeArgs { area }, input) = args.process()?; let range = area.item; let (from, left_inclusive) = range.from; @@ -59,7 +59,7 @@ fn range(args: CommandArgs) -> Result { .skip(from) .take(to - from + 1) .map(ReturnSuccess::value) - .to_output_stream()) + .to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/reduce.rs b/crates/nu-command/src/commands/reduce.rs index 9496f0becfe4..660aa28af205 100644 --- a/crates/nu-command/src/commands/reduce.rs +++ b/crates/nu-command/src/commands/reduce.rs @@ -7,7 +7,7 @@ use nu_errors::ShellError; use nu_parser::ParserScope; use nu_protocol::{hir::CapturedBlock, Signature, SyntaxShape, UntaggedValue, Value}; use nu_source::Tagged; -use nu_stream::OutputStream; +use nu_stream::ActionStream; pub struct Reduce; @@ -47,7 +47,7 @@ impl WholeStreamCommand for Reduce { "Block must be (A, A) -> A unless --fold is selected, in which case it may be A, B -> A." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { reduce(args) } @@ -94,7 +94,7 @@ fn process_row( result } -fn reduce(raw_args: CommandArgs) -> Result { +fn reduce(raw_args: CommandArgs) -> Result { let span = raw_args.call_info.name_tag.span; let context = Arc::new(EvaluationContext::from_args(&raw_args)); let (reduce_args, mut input): (ReduceArgs, _) = raw_args.process()?; @@ -150,7 +150,7 @@ fn reduce(raw_args: CommandArgs) -> Result { result })? - .to_output_stream()) + .to_output_stream_with_actions()) } else { let initial = Ok(InputStream::one(start)); Ok(input @@ -177,7 +177,7 @@ fn reduce(raw_args: CommandArgs) -> Result { context.scope.exit_scope(); result })? - .to_output_stream()) + .to_output_stream_with_actions()) } } diff --git a/crates/nu-command/src/commands/reject.rs b/crates/nu-command/src/commands/reject.rs index 5d805e159dde..5ca4abb41ad7 100644 --- a/crates/nu-command/src/commands/reject.rs +++ b/crates/nu-command/src/commands/reject.rs @@ -25,7 +25,7 @@ impl WholeStreamCommand for Reject { "Remove the given columns from the table. If you want to remove rows, try 'drop'." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { reject(args) } @@ -38,7 +38,7 @@ impl WholeStreamCommand for Reject { } } -fn reject(args: CommandArgs) -> Result { +fn reject(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let (RejectArgs { rest: fields }, input) = args.process()?; if fields.is_empty() { @@ -53,7 +53,7 @@ fn reject(args: CommandArgs) -> Result { Ok(input .map(move |item| ReturnSuccess::value(reject_fields(&item, &fields, &item.tag))) - .to_output_stream()) + .to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/rename.rs b/crates/nu-command/src/commands/rename.rs index d7f29aad71f1..05f63fb9a965 100644 --- a/crates/nu-command/src/commands/rename.rs +++ b/crates/nu-command/src/commands/rename.rs @@ -32,7 +32,7 @@ impl WholeStreamCommand for Rename { "Creates a new table with columns renamed." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { rename(args) } @@ -61,7 +61,7 @@ impl WholeStreamCommand for Rename { } } -pub fn rename(args: CommandArgs) -> Result { +pub fn rename(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let (Arguments { column_name, rest }, input) = args.process()?; let mut new_column_names = vec![vec![column_name]]; @@ -102,7 +102,7 @@ pub fn rename(args: CommandArgs) -> Result { ) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/reverse.rs b/crates/nu-command/src/commands/reverse.rs index da6dd4384ab1..51e91b85536f 100644 --- a/crates/nu-command/src/commands/reverse.rs +++ b/crates/nu-command/src/commands/reverse.rs @@ -18,7 +18,7 @@ impl WholeStreamCommand for Reverse { "Reverses the table." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { reverse(args) } @@ -37,12 +37,12 @@ impl WholeStreamCommand for Reverse { } } -fn reverse(args: CommandArgs) -> Result { +fn reverse(args: CommandArgs) -> Result { let args = args.evaluate_once()?; let (input, _args) = args.parts(); let input = input.collect::>(); - Ok((input.into_iter().rev().map(ReturnSuccess::value)).to_output_stream()) + Ok((input.into_iter().rev().map(ReturnSuccess::value)).to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/rm.rs b/crates/nu-command/src/commands/rm.rs index b9149c4526a7..cdf4fef7153d 100644 --- a/crates/nu-command/src/commands/rm.rs +++ b/crates/nu-command/src/commands/rm.rs @@ -32,7 +32,7 @@ impl WholeStreamCommand for Remove { "Remove file(s)." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { rm(args) } @@ -62,13 +62,13 @@ impl WholeStreamCommand for Remove { } } -fn rm(args: CommandArgs) -> Result { +fn rm(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let shell_manager = args.shell_manager.clone(); let (args, _): (RemoveArgs, _) = args.process()?; if args.trash.item && args.permanent.item { - return Ok(OutputStream::one(Err(ShellError::labeled_error( + return Ok(ActionStream::one(Err(ShellError::labeled_error( "only one of --permanent and --trash can be used", "conflicting flags", name, diff --git a/crates/nu-command/src/commands/roll/column.rs b/crates/nu-command/src/commands/roll/column.rs index 759a84fdff80..bf9cd8ab90b5 100644 --- a/crates/nu-command/src/commands/roll/column.rs +++ b/crates/nu-command/src/commands/roll/column.rs @@ -47,12 +47,12 @@ impl WholeStreamCommand for SubCommand { "Rolls the table columns" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { roll(args) } } -pub fn roll(args: CommandArgs) -> Result { +pub fn roll(args: CommandArgs) -> Result { let (args, input) = args.process()?; Ok(input @@ -65,7 +65,7 @@ pub fn roll(args: CommandArgs) -> Result { .map(ReturnSuccess::value) }) .flatten() - .to_output_stream()) + .to_output_stream_with_actions()) } fn roll_by(value: Value, options: &Arguments) -> Option> { diff --git a/crates/nu-command/src/commands/roll/command.rs b/crates/nu-command/src/commands/roll/command.rs index a470a065fbd6..de07aec83590 100644 --- a/crates/nu-command/src/commands/roll/command.rs +++ b/crates/nu-command/src/commands/roll/command.rs @@ -26,12 +26,12 @@ impl WholeStreamCommand for Command { "Rolls the table rows." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { roll(args) } } -pub fn roll(args: CommandArgs) -> Result { +pub fn roll(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let (args, mut input) = args.process()?; @@ -41,7 +41,7 @@ pub fn roll(args: CommandArgs) -> Result { .unwrap_or_else(|| vec![UntaggedValue::nothing().into_value(&name)]) .into_iter() .map(ReturnSuccess::value)) - .to_output_stream()) + .to_output_stream_with_actions()) } fn roll_down(values: Vec, Arguments { by: ref n }: &Arguments) -> Option> { diff --git a/crates/nu-command/src/commands/roll/up.rs b/crates/nu-command/src/commands/roll/up.rs index d0129184142b..194a549aa0b6 100644 --- a/crates/nu-command/src/commands/roll/up.rs +++ b/crates/nu-command/src/commands/roll/up.rs @@ -26,12 +26,12 @@ impl WholeStreamCommand for SubCommand { "Rolls the table rows" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { roll(args) } } -pub fn roll(args: CommandArgs) -> Result { +pub fn roll(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let (args, mut input) = args.process()?; @@ -41,7 +41,7 @@ pub fn roll(args: CommandArgs) -> Result { .unwrap_or_else(|| vec![UntaggedValue::nothing().into_value(&name)]) .into_iter() .map(ReturnSuccess::value)) - .to_output_stream()) + .to_output_stream_with_actions()) } fn roll_up(values: Vec, Arguments { by: ref n }: &Arguments) -> Option> { diff --git a/crates/nu-command/src/commands/rotate/command.rs b/crates/nu-command/src/commands/rotate/command.rs index b3287d3870f4..8bf2ff1c8a54 100644 --- a/crates/nu-command/src/commands/rotate/command.rs +++ b/crates/nu-command/src/commands/rotate/command.rs @@ -31,12 +31,12 @@ impl WholeStreamCommand for Command { "Rotates the table by 90 degrees clockwise." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { rotate(args) } } -pub fn rotate(args: CommandArgs) -> Result { +pub fn rotate(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let (Arguments { rest }, input) = args.process()?; @@ -48,7 +48,7 @@ pub fn rotate(args: CommandArgs) -> Result { let descs = descs.into_iter().rev().collect::>(); if total_rows == 0 { - return Ok(OutputStream::empty()); + return Ok(ActionStream::empty()); } let mut headers: Vec = vec![]; @@ -113,5 +113,5 @@ pub fn rotate(args: CommandArgs) -> Result { .rev() .collect::>()) .into_iter() - .to_output_stream()) + .to_output_stream_with_actions()) } diff --git a/crates/nu-command/src/commands/rotate/counter_clockwise.rs b/crates/nu-command/src/commands/rotate/counter_clockwise.rs index 17e7548a828c..f2d12d699cb9 100644 --- a/crates/nu-command/src/commands/rotate/counter_clockwise.rs +++ b/crates/nu-command/src/commands/rotate/counter_clockwise.rs @@ -31,12 +31,12 @@ impl WholeStreamCommand for SubCommand { "Rotates the table by 90 degrees counter clockwise." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { rotate(args) } } -pub fn rotate(args: CommandArgs) -> Result { +pub fn rotate(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let (Arguments { rest }, input) = args.process()?; @@ -45,7 +45,7 @@ pub fn rotate(args: CommandArgs) -> Result { let total_rows = input.len(); if total_rows == 0 { - return Ok(OutputStream::empty()); + return Ok(ActionStream::empty()); } let mut headers: Vec = vec![]; @@ -109,5 +109,5 @@ pub fn rotate(args: CommandArgs) -> Result { }) .collect::>()) .into_iter() - .to_output_stream()) + .to_output_stream_with_actions()) } diff --git a/crates/nu-command/src/commands/run_external.rs b/crates/nu-command/src/commands/run_external.rs index 666a23e2b96e..3eac861d98fe 100644 --- a/crates/nu-command/src/commands/run_external.rs +++ b/crates/nu-command/src/commands/run_external.rs @@ -62,7 +62,7 @@ impl WholeStreamCommand for RunExternalCommand { true } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let positionals = args.call_info.args.positional.clone().ok_or_else(|| { ShellError::untagged_runtime_error("positional arguments unexpectedly empty") })?; @@ -116,7 +116,7 @@ impl WholeStreamCommand for RunExternalCommand { .shell_manager .cd(cd_args, args.call_info.name_tag.clone()); - return Ok(result?.to_output_stream()); + return Ok(result?.to_output_stream_with_actions()); } } @@ -128,7 +128,7 @@ impl WholeStreamCommand for RunExternalCommand { external_redirection, ); - Ok(result?.to_output_stream()) + Ok(result?.to_output_stream_with_actions()) } } diff --git a/crates/nu-command/src/commands/save.rs b/crates/nu-command/src/commands/save.rs index 59708c715b97..edd84594b8d7 100644 --- a/crates/nu-command/src/commands/save.rs +++ b/crates/nu-command/src/commands/save.rs @@ -155,12 +155,12 @@ impl WholeStreamCommand for Save { "Save the contents of the pipeline to a file." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { save(args) } } -fn save(raw_args: CommandArgs) -> Result { +fn save(raw_args: CommandArgs) -> Result { let mut full_path = PathBuf::from(raw_args.shell_manager.path()); let name_tag = raw_args.call_info.name_tag.clone(); let name = raw_args.call_info.name_tag.clone(); @@ -230,7 +230,7 @@ fn save(raw_args: CommandArgs) -> Result { }, scope, }; - let mut result = converter.run(new_args.with_input(input))?; + let mut result = converter.run_with_actions(new_args.with_input(input))?; let result_vec: Vec> = result.drain_vec(); if converter.is_binary() { process_binary_return_success!('scope, result_vec, name_tag) diff --git a/crates/nu-command/src/commands/select.rs b/crates/nu-command/src/commands/select.rs index 83947f52034d..d9afbe0b3da5 100644 --- a/crates/nu-command/src/commands/select.rs +++ b/crates/nu-command/src/commands/select.rs @@ -28,7 +28,7 @@ impl WholeStreamCommand for Command { "Down-select table to only these columns." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { select(args) } @@ -48,7 +48,7 @@ impl WholeStreamCommand for Command { } } -fn select(args: CommandArgs) -> Result { +fn select(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let (Arguments { mut rest }, input) = args.process()?; let (columns, _) = arguments(&mut rest)?; @@ -155,5 +155,5 @@ fn select(args: CommandArgs) -> Result { ReturnSuccess::value(out.into_value()) })) - .to_output_stream()) + .to_output_stream_with_actions()) } diff --git a/crates/nu-command/src/commands/seq.rs b/crates/nu-command/src/commands/seq.rs index ce00257da1ba..e7626f569ab3 100644 --- a/crates/nu-command/src/commands/seq.rs +++ b/crates/nu-command/src/commands/seq.rs @@ -2,7 +2,7 @@ use crate::prelude::*; use nu_engine::WholeStreamCommand; use nu_errors::ShellError; use nu_protocol::value::StrExt; -use nu_protocol::{ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value}; +use nu_protocol::{Signature, SyntaxShape, UntaggedValue, Value}; use nu_source::Tagged; use std::cmp; @@ -317,5 +317,5 @@ fn print_seq( .lines() .map(|v| v.to_str_value_create_tag()) .collect(); - (rows.into_iter().map(ReturnSuccess::value)).to_output_stream() + (rows.into_iter()).to_output_stream() } diff --git a/crates/nu-command/src/commands/seq_dates.rs b/crates/nu-command/src/commands/seq_dates.rs index 99a7c263caaf..70a4e38f0411 100644 --- a/crates/nu-command/src/commands/seq_dates.rs +++ b/crates/nu-command/src/commands/seq_dates.rs @@ -72,7 +72,7 @@ impl WholeStreamCommand for SeqDates { "print sequences of dates" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { seq_dates(args) } @@ -131,7 +131,7 @@ impl WholeStreamCommand for SeqDates { } } -fn seq_dates(args: CommandArgs) -> Result { +fn seq_dates(args: CommandArgs) -> Result { let _name = args.call_info.name_tag.clone(); let ( @@ -230,7 +230,7 @@ pub fn run_seq_dates( increment: Value, day_count: Option, reverse: bool, -) -> Result { +) -> Result { let today = Local::today().naive_local(); let mut step_size: i64 = increment .as_i64() @@ -353,7 +353,7 @@ pub fn run_seq_dates( .lines() .map(|v| v.to_str_value_create_tag()) .collect(); - Ok((rows.into_iter().map(ReturnSuccess::value)).to_output_stream()) + Ok((rows.into_iter().map(ReturnSuccess::value)).to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/shells.rs b/crates/nu-command/src/commands/shells.rs index b833a76df8a3..207fc01e4744 100644 --- a/crates/nu-command/src/commands/shells.rs +++ b/crates/nu-command/src/commands/shells.rs @@ -19,12 +19,12 @@ impl WholeStreamCommand for Shells { "Display the list of current shells." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { Ok(shells(args)) } } -fn shells(args: CommandArgs) -> OutputStream { +fn shells(args: CommandArgs) -> ActionStream { let mut shells_out = VecDeque::new(); let tag = args.call_info.name_tag; diff --git a/crates/nu-command/src/commands/shuffle.rs b/crates/nu-command/src/commands/shuffle.rs index ce1e5eca01e3..edf625bbebbc 100644 --- a/crates/nu-command/src/commands/shuffle.rs +++ b/crates/nu-command/src/commands/shuffle.rs @@ -17,12 +17,12 @@ impl WholeStreamCommand for Shuffle { "Shuffle rows randomly." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { Ok(shuffle(args)) } } -fn shuffle(args: CommandArgs) -> OutputStream { +fn shuffle(args: CommandArgs) -> ActionStream { let input = args.input; let mut values: Vec = input.collect(); @@ -31,7 +31,7 @@ fn shuffle(args: CommandArgs) -> OutputStream { values .into_iter() .map(ReturnSuccess::value) - .to_output_stream() + .to_output_stream_with_actions() } #[cfg(test)] diff --git a/crates/nu-command/src/commands/size.rs b/crates/nu-command/src/commands/size.rs index 16e7027bff5b..3cd7ed9c63a1 100644 --- a/crates/nu-command/src/commands/size.rs +++ b/crates/nu-command/src/commands/size.rs @@ -22,7 +22,7 @@ impl WholeStreamCommand for Size { "Gather word count statistics on the text." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { Ok(size(args)) } @@ -54,7 +54,7 @@ impl WholeStreamCommand for Size { } } -fn size(args: CommandArgs) -> OutputStream { +fn size(args: CommandArgs) -> ActionStream { let input = args.input; let tag = args.call_info.name_tag; let name_span = tag.span; @@ -73,7 +73,7 @@ fn size(args: CommandArgs) -> OutputStream { )) } }) - .to_output_stream() + .to_output_stream_with_actions() } fn count(contents: &str, tag: impl Into) -> Value { diff --git a/crates/nu-command/src/commands/skip/command.rs b/crates/nu-command/src/commands/skip/command.rs index 5b98b2db6e53..0ec4f0445398 100644 --- a/crates/nu-command/src/commands/skip/command.rs +++ b/crates/nu-command/src/commands/skip/command.rs @@ -24,7 +24,7 @@ impl WholeStreamCommand for Command { "Skip some number of rows." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { skip(args) } @@ -40,7 +40,7 @@ impl WholeStreamCommand for Command { } } -fn skip(args: CommandArgs) -> Result { +fn skip(args: CommandArgs) -> Result { let (Arguments { rows }, input) = args.process()?; let rows_desired = if let Some(quantity) = rows { *quantity @@ -48,7 +48,7 @@ fn skip(args: CommandArgs) -> Result { 1 }; - Ok(input.skip(rows_desired).to_output_stream()) + Ok(input.skip(rows_desired).to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/skip/until.rs b/crates/nu-command/src/commands/skip/until.rs index bd209f727973..e040c8b7bad2 100644 --- a/crates/nu-command/src/commands/skip/until.rs +++ b/crates/nu-command/src/commands/skip/until.rs @@ -26,7 +26,7 @@ impl WholeStreamCommand for SubCommand { "Skips rows until the condition matches." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let ctx = Arc::new(EvaluationContext::from_args(&args)); let call_info = args.evaluate_once()?; @@ -92,7 +92,7 @@ impl WholeStreamCommand for SubCommand { !matches!(result, Ok(ref v) if v.is_true()) }) - .to_output_stream()) + .to_output_stream_with_actions()) } } diff --git a/crates/nu-command/src/commands/skip/while_.rs b/crates/nu-command/src/commands/skip/while_.rs index 874ac3e23bc0..254f06af74dc 100644 --- a/crates/nu-command/src/commands/skip/while_.rs +++ b/crates/nu-command/src/commands/skip/while_.rs @@ -26,7 +26,7 @@ impl WholeStreamCommand for SubCommand { "Skips rows while the condition matches." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let ctx = Arc::new(EvaluationContext::from_args(&args)); let call_info = args.evaluate_once()?; @@ -93,7 +93,7 @@ impl WholeStreamCommand for SubCommand { matches!(result, Ok(ref v) if v.is_true()) }) - .to_output_stream()) + .to_output_stream_with_actions()) } } diff --git a/crates/nu-command/src/commands/sleep.rs b/crates/nu-command/src/commands/sleep.rs index ff6b5ec72eab..2a4a5d56ec72 100644 --- a/crates/nu-command/src/commands/sleep.rs +++ b/crates/nu-command/src/commands/sleep.rs @@ -34,7 +34,7 @@ impl WholeStreamCommand for Sleep { "Delay for a specified amount of time." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let ctrl_c = args.ctrl_c().clone(); let (SleepArgs { duration, rest }, _) = args.process()?; @@ -50,7 +50,7 @@ impl WholeStreamCommand for Sleep { // `echo | sleep 1sec` - nothing // `sleep 1sec` - table with 0 elements - Ok(SleepIterator::new(total_dur, ctrl_c).to_output_stream()) + Ok(SleepIterator::new(total_dur, ctrl_c).to_output_stream_with_actions()) // if input.is_empty() { // Ok(OutputStream::empty()) diff --git a/crates/nu-command/src/commands/sort_by.rs b/crates/nu-command/src/commands/sort_by.rs index 5fa8d8f2b76e..91685be5a707 100644 --- a/crates/nu-command/src/commands/sort_by.rs +++ b/crates/nu-command/src/commands/sort_by.rs @@ -35,7 +35,7 @@ impl WholeStreamCommand for SortBy { "Sort by the given columns, in increasing order." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { sort_by(args) } @@ -111,7 +111,7 @@ impl WholeStreamCommand for SortBy { } } -fn sort_by(args: CommandArgs) -> Result { +fn sort_by(args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let ( @@ -130,7 +130,7 @@ fn sort_by(args: CommandArgs) -> Result { vec.reverse() } - Ok((vec.into_iter()).to_output_stream()) + Ok((vec.into_iter()).to_output_stream_with_actions()) } pub fn sort( diff --git a/crates/nu-command/src/commands/source.rs b/crates/nu-command/src/commands/source.rs index 228ae00caeba..ab2a8ee52849 100644 --- a/crates/nu-command/src/commands/source.rs +++ b/crates/nu-command/src/commands/source.rs @@ -30,7 +30,7 @@ impl WholeStreamCommand for Source { "Runs a script file in the current context." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { source(args) } @@ -39,7 +39,7 @@ impl WholeStreamCommand for Source { } } -pub fn source(args: CommandArgs) -> Result { +pub fn source(args: CommandArgs) -> Result { let ctx = EvaluationContext::from_args(&args); let (SourceArgs { filename }, _) = args.process()?; @@ -54,7 +54,7 @@ pub fn source(args: CommandArgs) -> Result { if let Err(err) = result { ctx.error(err.into()); } - Ok(OutputStream::empty()) + Ok(ActionStream::empty()) } Err(_) => { ctx.error(ShellError::labeled_error( @@ -63,7 +63,7 @@ pub fn source(args: CommandArgs) -> Result { filename.span(), )); - Ok(OutputStream::empty()) + Ok(ActionStream::empty()) } } } diff --git a/crates/nu-command/src/commands/split/chars.rs b/crates/nu-command/src/commands/split/chars.rs index 86dcab38a9b2..f361baf4e565 100644 --- a/crates/nu-command/src/commands/split/chars.rs +++ b/crates/nu-command/src/commands/split/chars.rs @@ -18,7 +18,7 @@ impl WholeStreamCommand for SubCommand { "splits a string's characters into separate rows" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { Ok(split_chars(args)) } @@ -37,7 +37,7 @@ impl WholeStreamCommand for SubCommand { } } -fn split_chars(args: CommandArgs) -> OutputStream { +fn split_chars(args: CommandArgs) -> ActionStream { let name = args.call_info.name_tag.clone(); let input = args.input; input @@ -47,9 +47,9 @@ fn split_chars(args: CommandArgs) -> OutputStream { .collect::>() .into_iter() .map(move |x| ReturnSuccess::value(Value::from(x.to_string()))) - .to_output_stream() + .to_output_stream_with_actions() } else { - OutputStream::one(Err(ShellError::labeled_error_with_secondary( + ActionStream::one(Err(ShellError::labeled_error_with_secondary( "Expected a string from pipeline", "requires string input", name.span, @@ -58,7 +58,7 @@ fn split_chars(args: CommandArgs) -> OutputStream { ))) } }) - .to_output_stream() + .to_output_stream_with_actions() } #[cfg(test)] diff --git a/crates/nu-command/src/commands/split/column.rs b/crates/nu-command/src/commands/split/column.rs index 2f8f7d4e3314..e4fbfb9a074a 100644 --- a/crates/nu-command/src/commands/split/column.rs +++ b/crates/nu-command/src/commands/split/column.rs @@ -37,12 +37,12 @@ impl WholeStreamCommand for SubCommand { "splits contents across multiple columns via the separator." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { split_column(args) } } -fn split_column(args: CommandArgs) -> Result { +fn split_column(args: CommandArgs) -> Result { let name_span = args.call_info.name_tag.span; let ( SplitColumnArgs { @@ -102,7 +102,7 @@ fn split_column(args: CommandArgs) -> Result { )) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/split/command.rs b/crates/nu-command/src/commands/split/command.rs index d2fc9a0fbe7a..f4823c710f93 100644 --- a/crates/nu-command/src/commands/split/command.rs +++ b/crates/nu-command/src/commands/split/command.rs @@ -19,8 +19,8 @@ impl WholeStreamCommand for Command { "Split contents across desired subcommand (like row, column) via the separator." } - fn run(&self, args: CommandArgs) -> Result { - Ok(OutputStream::one(Ok(ReturnSuccess::Value( + fn run_with_actions(&self, args: CommandArgs) -> Result { + Ok(ActionStream::one(Ok(ReturnSuccess::Value( UntaggedValue::string(get_full_help(&Command, &args.scope)).into_value(Tag::unknown()), )))) } diff --git a/crates/nu-command/src/commands/split/row.rs b/crates/nu-command/src/commands/split/row.rs index 4c4b7a93925a..943a8da3ff18 100644 --- a/crates/nu-command/src/commands/split/row.rs +++ b/crates/nu-command/src/commands/split/row.rs @@ -29,12 +29,12 @@ impl WholeStreamCommand for SubCommand { "splits contents over multiple rows via the separator." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { split_row(args) } } -fn split_row(args: CommandArgs) -> Result { +fn split_row(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let (SplitRowArgs { separator }, input) = args.process()?; Ok(input @@ -60,9 +60,9 @@ fn split_row(args: CommandArgs) -> Result { UntaggedValue::Primitive(Primitive::String(s)).into_value(&v.tag), ) })) - .to_output_stream() + .to_output_stream_with_actions() } else { - OutputStream::one(Err(ShellError::labeled_error_with_secondary( + ActionStream::one(Err(ShellError::labeled_error_with_secondary( "Expected a string from pipeline", "requires string input", name.span, @@ -71,7 +71,7 @@ fn split_row(args: CommandArgs) -> Result { ))) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/split_by.rs b/crates/nu-command/src/commands/split_by.rs index 4a2dcc50d576..3ddb5caed3ad 100644 --- a/crates/nu-command/src/commands/split_by.rs +++ b/crates/nu-command/src/commands/split_by.rs @@ -30,12 +30,12 @@ impl WholeStreamCommand for SplitBy { "Creates a new table with the data from the inner tables split by the column given." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { split_by(args) } } -pub fn split_by(args: CommandArgs) -> Result { +pub fn split_by(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let (SplitByArgs { column_name }, input) = args.process()?; let values: Vec = input.collect(); @@ -49,7 +49,7 @@ pub fn split_by(args: CommandArgs) -> Result { } let split = split(&column_name, &values[0], &name)?; - Ok(OutputStream::one(ReturnSuccess::value(split))) + Ok(ActionStream::one(ReturnSuccess::value(split))) } enum Grouper { diff --git a/crates/nu-command/src/commands/str_/capitalize.rs b/crates/nu-command/src/commands/str_/capitalize.rs index b6024286a11f..707464369a2e 100644 --- a/crates/nu-command/src/commands/str_/capitalize.rs +++ b/crates/nu-command/src/commands/str_/capitalize.rs @@ -30,7 +30,7 @@ impl WholeStreamCommand for SubCommand { "capitalizes text" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args) } @@ -43,7 +43,7 @@ impl WholeStreamCommand for SubCommand { } } -fn operate(args: CommandArgs) -> Result { +fn operate(args: CommandArgs) -> Result { let (options, input) = args.extract(|params| { Ok(Arguments { column_paths: params.rest_args()?, @@ -67,7 +67,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } fn action(input: &Value, tag: impl Into) -> Result { diff --git a/crates/nu-command/src/commands/str_/case/camel_case.rs b/crates/nu-command/src/commands/str_/case/camel_case.rs index f462a43789aa..9f5a97126345 100644 --- a/crates/nu-command/src/commands/str_/case/camel_case.rs +++ b/crates/nu-command/src/commands/str_/case/camel_case.rs @@ -23,7 +23,7 @@ impl WholeStreamCommand for SubCommand { "converts a string to camelCase" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args, &to_camel_case) } diff --git a/crates/nu-command/src/commands/str_/case/kebab_case.rs b/crates/nu-command/src/commands/str_/case/kebab_case.rs index 3642261af2ae..f99568a418a2 100644 --- a/crates/nu-command/src/commands/str_/case/kebab_case.rs +++ b/crates/nu-command/src/commands/str_/case/kebab_case.rs @@ -23,7 +23,7 @@ impl WholeStreamCommand for SubCommand { "converts a string to kebab-case" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args, &to_kebab_case) } diff --git a/crates/nu-command/src/commands/str_/case/mod.rs b/crates/nu-command/src/commands/str_/case/mod.rs index 8d572deb3315..103c9cdc6ebe 100644 --- a/crates/nu-command/src/commands/str_/case/mod.rs +++ b/crates/nu-command/src/commands/str_/case/mod.rs @@ -20,7 +20,7 @@ struct Arguments { column_paths: Vec, } -pub fn operate(args: CommandArgs, case_operation: &'static F) -> Result +pub fn operate(args: CommandArgs, case_operation: &'static F) -> Result where F: Fn(&str) -> String + Send + Sync + 'static, { @@ -47,7 +47,7 @@ where ReturnSuccess::value(ret) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } pub fn action( diff --git a/crates/nu-command/src/commands/str_/case/pascal_case.rs b/crates/nu-command/src/commands/str_/case/pascal_case.rs index b085e96d35be..a56324055c1b 100644 --- a/crates/nu-command/src/commands/str_/case/pascal_case.rs +++ b/crates/nu-command/src/commands/str_/case/pascal_case.rs @@ -23,7 +23,7 @@ impl WholeStreamCommand for SubCommand { "converts a string to PascalCase" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args, &to_pascal_case) } diff --git a/crates/nu-command/src/commands/str_/case/screaming_snake_case.rs b/crates/nu-command/src/commands/str_/case/screaming_snake_case.rs index 5f5120901846..917e8f6bead0 100644 --- a/crates/nu-command/src/commands/str_/case/screaming_snake_case.rs +++ b/crates/nu-command/src/commands/str_/case/screaming_snake_case.rs @@ -23,7 +23,7 @@ impl WholeStreamCommand for SubCommand { "converts a string to SCREAMING_SNAKE_CASE" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args, &to_screaming_snake_case) } diff --git a/crates/nu-command/src/commands/str_/case/snake_case.rs b/crates/nu-command/src/commands/str_/case/snake_case.rs index 43a4f12910df..ce73b06ee1c7 100644 --- a/crates/nu-command/src/commands/str_/case/snake_case.rs +++ b/crates/nu-command/src/commands/str_/case/snake_case.rs @@ -23,7 +23,7 @@ impl WholeStreamCommand for SubCommand { "converts a string to snake_case" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args, &to_snake_case) } diff --git a/crates/nu-command/src/commands/str_/collect.rs b/crates/nu-command/src/commands/str_/collect.rs index 47dc014595e6..3960daf59d88 100644 --- a/crates/nu-command/src/commands/str_/collect.rs +++ b/crates/nu-command/src/commands/str_/collect.rs @@ -33,7 +33,7 @@ impl WholeStreamCommand for SubCommand { "collects a list of strings into a string" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { collect(args) } @@ -46,7 +46,7 @@ impl WholeStreamCommand for SubCommand { } } -pub fn collect(args: CommandArgs) -> Result { +pub fn collect(args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let (options, input) = args.extract(|params| { @@ -68,7 +68,7 @@ pub fn collect(args: CommandArgs) -> Result { Ok(strings) => { let output = strings.join(&separator); - Ok(OutputStream::one(ReturnSuccess::value( + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::string(output).into_value(tag), ))) } diff --git a/crates/nu-command/src/commands/str_/command.rs b/crates/nu-command/src/commands/str_/command.rs index b235eb095d32..fbafae06ec28 100644 --- a/crates/nu-command/src/commands/str_/command.rs +++ b/crates/nu-command/src/commands/str_/command.rs @@ -21,8 +21,8 @@ impl WholeStreamCommand for Command { "Apply string function." } - fn run(&self, args: CommandArgs) -> Result { - Ok(OutputStream::one(ReturnSuccess::value( + fn run_with_actions(&self, args: CommandArgs) -> Result { + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::string(get_full_help(&Command, &args.scope)).into_value(Tag::unknown()), ))) } diff --git a/crates/nu-command/src/commands/str_/contains.rs b/crates/nu-command/src/commands/str_/contains.rs index 674b8293dd5b..8b6dd4944834 100644 --- a/crates/nu-command/src/commands/str_/contains.rs +++ b/crates/nu-command/src/commands/str_/contains.rs @@ -35,7 +35,7 @@ impl WholeStreamCommand for SubCommand { "Checks if string contains pattern" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args) } @@ -55,7 +55,7 @@ impl WholeStreamCommand for SubCommand { } } -fn operate(args: CommandArgs) -> Result { +fn operate(args: CommandArgs) -> Result { let (options, input) = args.extract(|params| { Ok(Arc::new(Arguments { pattern: params.req(0)?, @@ -83,7 +83,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } fn action( diff --git a/crates/nu-command/src/commands/str_/downcase.rs b/crates/nu-command/src/commands/str_/downcase.rs index 82df78c61652..d14aa63dea68 100644 --- a/crates/nu-command/src/commands/str_/downcase.rs +++ b/crates/nu-command/src/commands/str_/downcase.rs @@ -30,7 +30,7 @@ impl WholeStreamCommand for SubCommand { "downcases text" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args) } @@ -43,7 +43,7 @@ impl WholeStreamCommand for SubCommand { } } -fn operate(args: CommandArgs) -> Result { +fn operate(args: CommandArgs) -> Result { let (options, input) = args.extract(|params| { Ok(Arguments { column_paths: params.rest_args()?, @@ -67,7 +67,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } fn action(input: &Value, tag: impl Into) -> Result { diff --git a/crates/nu-command/src/commands/str_/ends_with.rs b/crates/nu-command/src/commands/str_/ends_with.rs index da7d334d3474..1f373c9eb606 100644 --- a/crates/nu-command/src/commands/str_/ends_with.rs +++ b/crates/nu-command/src/commands/str_/ends_with.rs @@ -33,7 +33,7 @@ impl WholeStreamCommand for SubCommand { "checks if string ends with pattern" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args) } @@ -46,7 +46,7 @@ impl WholeStreamCommand for SubCommand { } } -fn operate(args: CommandArgs) -> Result { +fn operate(args: CommandArgs) -> Result { let (options, input) = args.extract(|params| { Ok(Arc::new(Arguments { pattern: params.req(0)?, @@ -73,7 +73,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } fn action(input: &Value, pattern: &str, tag: impl Into) -> Result { diff --git a/crates/nu-command/src/commands/str_/find_replace.rs b/crates/nu-command/src/commands/str_/find_replace.rs index e9f4e5485da1..70360b2a5a83 100644 --- a/crates/nu-command/src/commands/str_/find_replace.rs +++ b/crates/nu-command/src/commands/str_/find_replace.rs @@ -38,7 +38,7 @@ impl WholeStreamCommand for SubCommand { "finds and replaces text" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args) } @@ -60,7 +60,7 @@ impl WholeStreamCommand for SubCommand { struct FindReplace<'a>(&'a str, &'a str); -fn operate(args: CommandArgs) -> Result { +fn operate(args: CommandArgs) -> Result { let (options, input) = args.extract(|params| { Ok(Arc::new(Arguments { all: params.has_flag("all"), @@ -89,7 +89,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } fn action( diff --git a/crates/nu-command/src/commands/str_/from.rs b/crates/nu-command/src/commands/str_/from.rs index 6f8172345b44..41b0c7787e76 100644 --- a/crates/nu-command/src/commands/str_/from.rs +++ b/crates/nu-command/src/commands/str_/from.rs @@ -43,7 +43,7 @@ impl WholeStreamCommand for SubCommand { "Converts numeric types to strings. Trims trailing zeros unless decimals parameter is specified." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args) } @@ -68,7 +68,7 @@ impl WholeStreamCommand for SubCommand { } } -fn operate(args: CommandArgs) -> Result { +fn operate(args: CommandArgs) -> Result { let (options, input) = args.extract(|params| { Ok(Arguments { decimals: if let Some(arg) = params.get_flag("decimals") { @@ -100,7 +100,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } // TODO If you're using the with-system-locale feature and you're on Windows, Clang 3.9 or higher is also required. diff --git a/crates/nu-command/src/commands/str_/index_of.rs b/crates/nu-command/src/commands/str_/index_of.rs index 1d959e4d1c79..9bee50a523d2 100644 --- a/crates/nu-command/src/commands/str_/index_of.rs +++ b/crates/nu-command/src/commands/str_/index_of.rs @@ -49,7 +49,7 @@ impl WholeStreamCommand for SubCommand { "Returns starting index of given pattern in string counting from 0. Returns -1 when there are no results." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args) } @@ -89,7 +89,7 @@ impl WholeStreamCommand for SubCommand { } } -fn operate(args: CommandArgs) -> Result { +fn operate(args: CommandArgs) -> Result { let (options, input) = args.extract(|params| { Ok(Arc::new(Arguments { pattern: params.req(0)?, @@ -122,7 +122,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } fn action( diff --git a/crates/nu-command/src/commands/str_/length.rs b/crates/nu-command/src/commands/str_/length.rs index d9a07009e560..501d83259de4 100644 --- a/crates/nu-command/src/commands/str_/length.rs +++ b/crates/nu-command/src/commands/str_/length.rs @@ -28,7 +28,7 @@ impl WholeStreamCommand for SubCommand { "outputs the lengths of the strings in the pipeline" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args) } @@ -51,7 +51,7 @@ impl WholeStreamCommand for SubCommand { } } -fn operate(args: CommandArgs) -> Result { +fn operate(args: CommandArgs) -> Result { let (options, input) = args.extract(|params| { Ok(Arguments { column_paths: params.rest_args()?, @@ -75,7 +75,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } fn action(input: &Value, tag: impl Into) -> Result { diff --git a/crates/nu-command/src/commands/str_/lpad.rs b/crates/nu-command/src/commands/str_/lpad.rs index d3342eb684bf..a23bfdc94e10 100644 --- a/crates/nu-command/src/commands/str_/lpad.rs +++ b/crates/nu-command/src/commands/str_/lpad.rs @@ -40,7 +40,7 @@ impl WholeStreamCommand for SubCommand { "pad a string with a character a certain length" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args) } @@ -76,7 +76,7 @@ impl WholeStreamCommand for SubCommand { } } -fn operate(args: CommandArgs) -> Result { +fn operate(args: CommandArgs) -> Result { let (options, input) = args.extract(|params| { Ok(Arc::new(Arguments { length: params.req_named("length")?, @@ -104,7 +104,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } fn action( diff --git a/crates/nu-command/src/commands/str_/reverse.rs b/crates/nu-command/src/commands/str_/reverse.rs index 8642ff2cb8e2..d22fc3a2de34 100644 --- a/crates/nu-command/src/commands/str_/reverse.rs +++ b/crates/nu-command/src/commands/str_/reverse.rs @@ -28,7 +28,7 @@ impl WholeStreamCommand for SubCommand { "outputs the reversals of the strings in the pipeline" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args) } @@ -41,7 +41,7 @@ impl WholeStreamCommand for SubCommand { } } -fn operate(args: CommandArgs) -> Result { +fn operate(args: CommandArgs) -> Result { let (options, input) = args.extract(|params| { Ok(Arguments { column_paths: params.rest_args()?, @@ -65,7 +65,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } fn action(input: &Value, tag: impl Into) -> Result { diff --git a/crates/nu-command/src/commands/str_/rpad.rs b/crates/nu-command/src/commands/str_/rpad.rs index f0848a1d8a46..4cdfad858fcf 100644 --- a/crates/nu-command/src/commands/str_/rpad.rs +++ b/crates/nu-command/src/commands/str_/rpad.rs @@ -40,7 +40,7 @@ impl WholeStreamCommand for SubCommand { "pad a string with a character a certain length" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args) } @@ -76,7 +76,7 @@ impl WholeStreamCommand for SubCommand { } } -fn operate(args: CommandArgs) -> Result { +fn operate(args: CommandArgs) -> Result { let (options, input) = args.extract(|params| { Ok(Arc::new(Arguments { length: params.req_named("length")?, @@ -104,7 +104,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } fn action( diff --git a/crates/nu-command/src/commands/str_/starts_with.rs b/crates/nu-command/src/commands/str_/starts_with.rs index dfd038647bbc..6bae40d64627 100644 --- a/crates/nu-command/src/commands/str_/starts_with.rs +++ b/crates/nu-command/src/commands/str_/starts_with.rs @@ -33,7 +33,7 @@ impl WholeStreamCommand for SubCommand { "checks if string starts with pattern" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args) } @@ -46,7 +46,7 @@ impl WholeStreamCommand for SubCommand { } } -fn operate(args: CommandArgs) -> Result { +fn operate(args: CommandArgs) -> Result { let (options, input) = args.extract(|params| { Ok(Arc::new(Arguments { pattern: params.req(0)?, @@ -73,7 +73,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } fn action(input: &Value, pattern: &str, tag: impl Into) -> Result { diff --git a/crates/nu-command/src/commands/str_/substring.rs b/crates/nu-command/src/commands/str_/substring.rs index 247d7ca1defe..f4f0ea203088 100644 --- a/crates/nu-command/src/commands/str_/substring.rs +++ b/crates/nu-command/src/commands/str_/substring.rs @@ -40,7 +40,7 @@ impl WholeStreamCommand for SubCommand { "substrings text" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args) } @@ -86,7 +86,7 @@ impl From<(isize, isize)> for Substring { struct SubstringText(String, String); -fn operate(args: CommandArgs) -> Result { +fn operate(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let (options, input) = args.extract(|params| { @@ -117,7 +117,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } fn action(input: &Value, options: &Substring, tag: impl Into) -> Result { diff --git a/crates/nu-command/src/commands/str_/to_datetime.rs b/crates/nu-command/src/commands/str_/to_datetime.rs index d27e95ab0d89..0ec5278d0ded 100644 --- a/crates/nu-command/src/commands/str_/to_datetime.rs +++ b/crates/nu-command/src/commands/str_/to_datetime.rs @@ -87,7 +87,7 @@ impl WholeStreamCommand for SubCommand { "converts text into datetime" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args) } @@ -126,7 +126,7 @@ impl WholeStreamCommand for SubCommand { #[derive(Clone)] struct DatetimeFormat(String); -fn operate(args: CommandArgs) -> Result { +fn operate(args: CommandArgs) -> Result { let (options, input) = args.extract(|params| { let (column_paths, _) = arguments(&mut params.rest_args()?)?; @@ -195,7 +195,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } fn action( diff --git a/crates/nu-command/src/commands/str_/to_decimal.rs b/crates/nu-command/src/commands/str_/to_decimal.rs index defc41c61510..6751e3a179df 100644 --- a/crates/nu-command/src/commands/str_/to_decimal.rs +++ b/crates/nu-command/src/commands/str_/to_decimal.rs @@ -33,7 +33,7 @@ impl WholeStreamCommand for SubCommand { "converts text into decimal" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args) } @@ -46,7 +46,7 @@ impl WholeStreamCommand for SubCommand { } } -fn operate(args: CommandArgs) -> Result { +fn operate(args: CommandArgs) -> Result { let (options, input) = args.extract(|params| { Ok(Arguments { column_paths: params.rest_args()?, @@ -70,7 +70,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } fn action(input: &Value, tag: impl Into) -> Result { diff --git a/crates/nu-command/src/commands/str_/to_integer.rs b/crates/nu-command/src/commands/str_/to_integer.rs index 10f7dc5a373e..a7881eb71f90 100644 --- a/crates/nu-command/src/commands/str_/to_integer.rs +++ b/crates/nu-command/src/commands/str_/to_integer.rs @@ -37,7 +37,7 @@ impl WholeStreamCommand for SubCommand { "converts text into integer" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args) } @@ -67,7 +67,7 @@ impl WholeStreamCommand for SubCommand { } } -fn operate(args: CommandArgs) -> Result { +fn operate(args: CommandArgs) -> Result { let (options, input) = args.extract(|params| { let (column_paths, _) = arguments(&mut params.rest_args()?)?; @@ -100,7 +100,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } fn action(input: &Value, tag: impl Into, radix: u32) -> Result { diff --git a/crates/nu-command/src/commands/str_/trim/mod.rs b/crates/nu-command/src/commands/str_/trim/mod.rs index cd42ae3d2caa..699bad4db043 100644 --- a/crates/nu-command/src/commands/str_/trim/mod.rs +++ b/crates/nu-command/src/commands/str_/trim/mod.rs @@ -19,7 +19,7 @@ struct Arguments { column_paths: Vec, } -pub fn operate(args: CommandArgs, trim_operation: &'static F) -> Result +pub fn operate(args: CommandArgs, trim_operation: &'static F) -> Result where F: Fn(&str, Option) -> String + Send + Sync + 'static, { @@ -61,7 +61,7 @@ where ReturnSuccess::value(ret) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } #[derive(Debug, Copy, Clone)] diff --git a/crates/nu-command/src/commands/str_/trim/trim_both_ends.rs b/crates/nu-command/src/commands/str_/trim/trim_both_ends.rs index abeb2c4b9a33..67e33cc50265 100644 --- a/crates/nu-command/src/commands/str_/trim/trim_both_ends.rs +++ b/crates/nu-command/src/commands/str_/trim/trim_both_ends.rs @@ -29,7 +29,7 @@ impl WholeStreamCommand for SubCommand { "trims text" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args, &trim) } diff --git a/crates/nu-command/src/commands/str_/trim/trim_left.rs b/crates/nu-command/src/commands/str_/trim/trim_left.rs index 3437f06cc1b3..a639265bdbbd 100644 --- a/crates/nu-command/src/commands/str_/trim/trim_left.rs +++ b/crates/nu-command/src/commands/str_/trim/trim_left.rs @@ -29,7 +29,7 @@ impl WholeStreamCommand for SubCommand { "trims whitespace or character from the beginning of text" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args, &trim_left) } diff --git a/crates/nu-command/src/commands/str_/trim/trim_right.rs b/crates/nu-command/src/commands/str_/trim/trim_right.rs index 35077edb3b98..619337eb2a8b 100644 --- a/crates/nu-command/src/commands/str_/trim/trim_right.rs +++ b/crates/nu-command/src/commands/str_/trim/trim_right.rs @@ -29,7 +29,7 @@ impl WholeStreamCommand for SubCommand { "trims whitespace or character from the end of text" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args, &trim_right) } diff --git a/crates/nu-command/src/commands/str_/upcase.rs b/crates/nu-command/src/commands/str_/upcase.rs index e41c8f5f64e1..703fcc93ac40 100644 --- a/crates/nu-command/src/commands/str_/upcase.rs +++ b/crates/nu-command/src/commands/str_/upcase.rs @@ -30,7 +30,7 @@ impl WholeStreamCommand for SubCommand { "upcases text" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { operate(args) } @@ -43,7 +43,7 @@ impl WholeStreamCommand for SubCommand { } } -fn operate(args: CommandArgs) -> Result { +fn operate(args: CommandArgs) -> Result { let (options, input) = args.extract(|params| { Ok(Arguments { column_paths: params.rest_args()?, @@ -67,7 +67,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } fn action(input: &Value, tag: impl Into) -> Result { diff --git a/crates/nu-command/src/commands/tags.rs b/crates/nu-command/src/commands/tags.rs index b2c5d72f996f..48013aed8ba2 100644 --- a/crates/nu-command/src/commands/tags.rs +++ b/crates/nu-command/src/commands/tags.rs @@ -18,12 +18,12 @@ impl WholeStreamCommand for Tags { "Read the tags (metadata) for values." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { Ok(tags(args)) } } -fn tags(args: CommandArgs) -> OutputStream { +fn tags(args: CommandArgs) -> ActionStream { args.input .map(move |v| { let mut tags = TaggedDictBuilder::new(v.tag()); @@ -48,7 +48,7 @@ fn tags(args: CommandArgs) -> OutputStream { tags.into_value() }) - .to_output_stream() + .to_output_stream_with_actions() } #[cfg(test)] diff --git a/crates/nu-command/src/commands/termsize.rs b/crates/nu-command/src/commands/termsize.rs index 2e7603d52932..559c2077a12d 100644 --- a/crates/nu-command/src/commands/termsize.rs +++ b/crates/nu-command/src/commands/termsize.rs @@ -27,7 +27,7 @@ impl WholeStreamCommand for TermSize { "Returns the terminal size as W H" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let (TermSizeArgs { wide, tall }, _) = args.process()?; @@ -35,18 +35,18 @@ impl WholeStreamCommand for TermSize { match size { Some((w, h)) => { if wide && !tall { - Ok(OutputStream::one(UntaggedValue::int(w).into_value(tag))) + Ok(ActionStream::one(UntaggedValue::int(w).into_value(tag))) } else if !wide && tall { - Ok(OutputStream::one(UntaggedValue::int(h).into_value(tag))) + Ok(ActionStream::one(UntaggedValue::int(h).into_value(tag))) } else { let mut indexmap = IndexMap::with_capacity(2); indexmap.insert("width".to_string(), UntaggedValue::int(w).into_value(&tag)); indexmap.insert("height".to_string(), UntaggedValue::int(h).into_value(&tag)); let value = UntaggedValue::Row(Dictionary::from(indexmap)).into_value(&tag); - Ok(OutputStream::one(value)) + Ok(ActionStream::one(value)) } } - _ => Ok(OutputStream::one( + _ => Ok(ActionStream::one( UntaggedValue::string("0 0".to_string()).into_value(tag), )), } diff --git a/crates/nu-command/src/commands/to.rs b/crates/nu-command/src/commands/to.rs index 52aeeb9d1ae6..14d5fba978bf 100644 --- a/crates/nu-command/src/commands/to.rs +++ b/crates/nu-command/src/commands/to.rs @@ -19,8 +19,8 @@ impl WholeStreamCommand for To { "Convert table into an output format (based on subcommand, like csv, html, json, yaml)." } - fn run(&self, args: CommandArgs) -> Result { - Ok(OutputStream::one(ReturnSuccess::value( + fn run_with_actions(&self, args: CommandArgs) -> Result { + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::string(get_full_help(&To, &args.scope)).into_value(Tag::unknown()), ))) } diff --git a/crates/nu-command/src/commands/to_csv.rs b/crates/nu-command/src/commands/to_csv.rs index 0e5d5e752e9e..9a37693ff130 100644 --- a/crates/nu-command/src/commands/to_csv.rs +++ b/crates/nu-command/src/commands/to_csv.rs @@ -36,12 +36,12 @@ impl WholeStreamCommand for ToCsv { "Convert table into .csv text " } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { to_csv(args) } } -fn to_csv(args: CommandArgs) -> Result { +fn to_csv(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let ( ToCsvArgs { diff --git a/crates/nu-command/src/commands/to_delimited_data.rs b/crates/nu-command/src/commands/to_delimited_data.rs index d070a4410235..3d920cde4529 100644 --- a/crates/nu-command/src/commands/to_delimited_data.rs +++ b/crates/nu-command/src/commands/to_delimited_data.rs @@ -170,7 +170,7 @@ pub fn to_delimited_data( format_name: &'static str, input: InputStream, name: Tag, -) -> Result { +) -> Result { let name_tag = name; let name_span = name_tag.span; @@ -217,5 +217,5 @@ pub fn to_delimited_data( } } })) - .to_output_stream()) + .to_output_stream_with_actions()) } diff --git a/crates/nu-command/src/commands/to_html.rs b/crates/nu-command/src/commands/to_html.rs index b792ae05579e..637a3e9f18a9 100644 --- a/crates/nu-command/src/commands/to_html.rs +++ b/crates/nu-command/src/commands/to_html.rs @@ -123,7 +123,7 @@ impl WholeStreamCommand for ToHtml { "Convert table into simple HTML" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { to_html(args) } } @@ -267,7 +267,7 @@ fn get_list_of_theme_names() -> Vec { theme_names } -fn to_html(args: CommandArgs) -> Result { +fn to_html(args: CommandArgs) -> Result { let name_tag = args.call_info.name_tag.clone(); let ( ToHtmlArgs { @@ -300,7 +300,7 @@ fn to_html(args: CommandArgs) -> Result { output_string.push_str("https://github.com/mbadolato/iTerm2-Color-Schemes\n"); // Short circuit and return the output_string - Ok(OutputStream::one(ReturnSuccess::value( + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::string(output_string).into_value(name_tag), ))) } else { @@ -376,7 +376,7 @@ fn to_html(args: CommandArgs) -> Result { output_string = run_regexes(®ex_hm, &output_string); } - Ok(OutputStream::one(ReturnSuccess::value( + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::string(output_string).into_value(name_tag), ))) } diff --git a/crates/nu-command/src/commands/to_json.rs b/crates/nu-command/src/commands/to_json.rs index 1062aa096d35..196e71ebce42 100644 --- a/crates/nu-command/src/commands/to_json.rs +++ b/crates/nu-command/src/commands/to_json.rs @@ -32,7 +32,7 @@ impl WholeStreamCommand for ToJson { "Converts table data into JSON text." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { to_json(args) } @@ -157,7 +157,7 @@ fn json_list(input: &[Value]) -> Result, ShellError> { Ok(out) } -fn to_json(args: CommandArgs) -> Result { +fn to_json(args: CommandArgs) -> Result { let name_tag = args.call_info.name_tag.clone(); let (ToJsonArgs { pretty }, input) = args.process()?; let name_span = name_tag.span; @@ -249,7 +249,7 @@ fn to_json(args: CommandArgs) -> Result { &name_tag, )), })) - .to_output_stream()) + .to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/to_md.rs b/crates/nu-command/src/commands/to_md.rs index 50aae08a66e4..af5e4594c20d 100644 --- a/crates/nu-command/src/commands/to_md.rs +++ b/crates/nu-command/src/commands/to_md.rs @@ -37,7 +37,7 @@ impl WholeStreamCommand for Command { "Convert table into simple Markdown" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { to_md(args) } @@ -82,13 +82,13 @@ impl WholeStreamCommand for Command { } } -fn to_md(args: CommandArgs) -> Result { +fn to_md(args: CommandArgs) -> Result { let name_tag = args.call_info.name_tag.clone(); let (arguments, input) = args.process()?; let input: Vec = input.collect(); - Ok(OutputStream::one(ReturnSuccess::value( + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::string(process(&input, arguments)).into_value(if input.is_empty() { name_tag } else { diff --git a/crates/nu-command/src/commands/to_toml.rs b/crates/nu-command/src/commands/to_toml.rs index 6210083f4b54..4aed6417e78d 100644 --- a/crates/nu-command/src/commands/to_toml.rs +++ b/crates/nu-command/src/commands/to_toml.rs @@ -18,7 +18,7 @@ impl WholeStreamCommand for ToToml { "Convert table into .toml text" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { to_toml(args) } // TODO: add an example here. What commands to run to get a Row(Dictionary)? @@ -139,7 +139,7 @@ fn collect_values(input: &[Value]) -> Result, ShellError> { Ok(out) } -fn to_toml(args: CommandArgs) -> Result { +fn to_toml(args: CommandArgs) -> Result { let args = args.evaluate_once()?; let name_tag = args.name_tag(); let name_span = name_tag.span; @@ -179,7 +179,7 @@ fn to_toml(args: CommandArgs) -> Result { )), } })) - .to_output_stream()) + .to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/to_tsv.rs b/crates/nu-command/src/commands/to_tsv.rs index 4341d3d27539..803748ba4a32 100644 --- a/crates/nu-command/src/commands/to_tsv.rs +++ b/crates/nu-command/src/commands/to_tsv.rs @@ -28,12 +28,12 @@ impl WholeStreamCommand for ToTsv { "Convert table into .tsv text" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { to_tsv(args) } } -fn to_tsv(args: CommandArgs) -> Result { +fn to_tsv(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let (ToTsvArgs { noheaders }, input) = args.process()?; diff --git a/crates/nu-command/src/commands/to_url.rs b/crates/nu-command/src/commands/to_url.rs index 43716331673e..25141ce757aa 100644 --- a/crates/nu-command/src/commands/to_url.rs +++ b/crates/nu-command/src/commands/to_url.rs @@ -18,12 +18,12 @@ impl WholeStreamCommand for ToUrl { "Convert table into url-encoded text" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { to_url(args) } } -fn to_url(args: CommandArgs) -> Result { +fn to_url(args: CommandArgs) -> Result { let args = args.evaluate_once()?; let tag = args.name_tag(); let input = args.input; @@ -69,7 +69,7 @@ fn to_url(args: CommandArgs) -> Result { value_tag.span, )), }) - .to_output_stream()) + .to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/to_xml.rs b/crates/nu-command/src/commands/to_xml.rs index c09b546c4e84..ad85ea00dbc4 100644 --- a/crates/nu-command/src/commands/to_xml.rs +++ b/crates/nu-command/src/commands/to_xml.rs @@ -33,7 +33,7 @@ impl WholeStreamCommand for ToXml { "Convert table into .xml text" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { to_xml(args) } } @@ -131,7 +131,7 @@ pub fn write_xml_events( Ok(()) } -fn to_xml(args: CommandArgs) -> Result { +fn to_xml(args: CommandArgs) -> Result { let name_tag = args.call_info.name_tag.clone(); let name_span = name_tag.span; let (ToXmlArgs { pretty }, input) = args.process()?; @@ -180,7 +180,7 @@ fn to_xml(args: CommandArgs) -> Result { )), } })) - .to_output_stream()) + .to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/to_yaml.rs b/crates/nu-command/src/commands/to_yaml.rs index 46aa38847ca7..e5c8deb381b8 100644 --- a/crates/nu-command/src/commands/to_yaml.rs +++ b/crates/nu-command/src/commands/to_yaml.rs @@ -18,7 +18,7 @@ impl WholeStreamCommand for ToYaml { "Convert table into .yaml/.yml text" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { to_yaml(args) } } @@ -113,7 +113,7 @@ pub fn value_to_yaml_value(v: &Value) -> Result { }) } -fn to_yaml(args: CommandArgs) -> Result { +fn to_yaml(args: CommandArgs) -> Result { let args = args.evaluate_once()?; let name_tag = args.name_tag(); let name_span = name_tag.span; @@ -155,7 +155,7 @@ fn to_yaml(args: CommandArgs) -> Result { )), } })) - .to_output_stream()) + .to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/touch.rs b/crates/nu-command/src/commands/touch.rs index 5757dc6b0ec7..d97491abfa9b 100644 --- a/crates/nu-command/src/commands/touch.rs +++ b/crates/nu-command/src/commands/touch.rs @@ -30,7 +30,7 @@ impl WholeStreamCommand for Touch { fn usage(&self) -> &str { "Creates one or more files." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { touch(args) } @@ -50,7 +50,7 @@ impl WholeStreamCommand for Touch { } } -fn touch(args: CommandArgs) -> Result { +fn touch(args: CommandArgs) -> Result { let (TouchArgs { target, rest }, _) = args.process()?; for item in vec![target].into_iter().chain(rest.into_iter()) { @@ -66,7 +66,7 @@ fn touch(args: CommandArgs) -> Result { } } - Ok(OutputStream::empty()) + Ok(ActionStream::empty()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/uniq.rs b/crates/nu-command/src/commands/uniq.rs index f0fc8b9900ee..02bd388bad6b 100644 --- a/crates/nu-command/src/commands/uniq.rs +++ b/crates/nu-command/src/commands/uniq.rs @@ -18,7 +18,7 @@ impl WholeStreamCommand for Uniq { "Return the unique rows." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { uniq(args) } @@ -53,7 +53,7 @@ impl WholeStreamCommand for Uniq { } } -fn uniq(args: CommandArgs) -> Result { +fn uniq(args: CommandArgs) -> Result { let args = args.evaluate_once()?; let should_show_count = args.has_flag("count"); let input = args.input; @@ -115,7 +115,7 @@ fn uniq(args: CommandArgs) -> Result { } } - Ok(values_vec_deque.into_iter().to_output_stream()) + Ok(values_vec_deque.into_iter().to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/update.rs b/crates/nu-command/src/commands/update.rs index 933ff44349e5..71b81cbc452b 100644 --- a/crates/nu-command/src/commands/update.rs +++ b/crates/nu-command/src/commands/update.rs @@ -39,7 +39,7 @@ impl WholeStreamCommand for Command { "Update an existing column to have a new value." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { update(args) } @@ -70,7 +70,7 @@ fn process_row( mut replacement: Arc, field: Arc, tag: Arc, -) -> Result { +) -> Result { let tag = &*tag; let replacement = Arc::make_mut(&mut replacement); @@ -121,21 +121,21 @@ fn process_row( value: UntaggedValue::Row(_), .. } => match obj.replace_data_at_column_path(&field, result) { - Some(v) => OutputStream::one(ReturnSuccess::value(v)), - None => OutputStream::one(Err(ShellError::labeled_error( + Some(v) => ActionStream::one(ReturnSuccess::value(v)), + None => ActionStream::one(Err(ShellError::labeled_error( "update could not find place to insert column", "column name", obj.tag, ))), }, - _ => OutputStream::one(Err(ShellError::labeled_error( + _ => ActionStream::one(Err(ShellError::labeled_error( "Unrecognized type in stream", "original value", block_tag.clone(), ))), } } - Err(e) => OutputStream::one(Err(e)), + Err(e) => ActionStream::one(Err(e)), } } replacement => match input { @@ -148,8 +148,8 @@ fn process_row( .unwrap_or_else(|| UntaggedValue::nothing().into_untagged_value()) .replace_data_at_column_path(&field, replacement.clone()) { - Some(v) => OutputStream::one(ReturnSuccess::value(v)), - None => OutputStream::one(Err(ShellError::labeled_error( + Some(v) => ActionStream::one(ReturnSuccess::value(v)), + None => ActionStream::one(Err(ShellError::labeled_error( "update could not find place to insert column", "column name", field.maybe_span().unwrap_or(tag.span), @@ -157,8 +157,8 @@ fn process_row( }, Value { value: _, ref tag } => { match input.replace_data_at_column_path(&field, replacement.clone()) { - Some(v) => OutputStream::one(ReturnSuccess::value(v)), - None => OutputStream::one(Err(ShellError::labeled_error( + Some(v) => ActionStream::one(ReturnSuccess::value(v)), + None => ActionStream::one(Err(ShellError::labeled_error( "update could not find place to insert column", "column name", field.maybe_span().unwrap_or(tag.span), @@ -169,7 +169,7 @@ fn process_row( }) } -fn update(raw_args: CommandArgs) -> Result { +fn update(raw_args: CommandArgs) -> Result { let name_tag = Arc::new(raw_args.call_info.name_tag.clone()); let context = Arc::new(EvaluationContext::from_args(&raw_args)); let (Arguments { field, replacement }, input) = raw_args.process()?; @@ -185,9 +185,9 @@ fn update(raw_args: CommandArgs) -> Result { match process_row(context, input, replacement, field, tag) { Ok(s) => s, - Err(e) => OutputStream::one(Err(e)), + Err(e) => ActionStream::one(Err(e)), } }) .flatten() - .to_output_stream()) + .to_output_stream_with_actions()) } diff --git a/crates/nu-command/src/commands/url_/command.rs b/crates/nu-command/src/commands/url_/command.rs index 72a7566ff5bb..f8244993d246 100644 --- a/crates/nu-command/src/commands/url_/command.rs +++ b/crates/nu-command/src/commands/url_/command.rs @@ -18,8 +18,8 @@ impl WholeStreamCommand for Url { "Apply url function." } - fn run(&self, args: CommandArgs) -> Result { - Ok(OutputStream::one(ReturnSuccess::value( + fn run_with_actions(&self, args: CommandArgs) -> Result { + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::string(get_full_help(&Url, &args.scope)).into_value(Tag::unknown()), ))) } diff --git a/crates/nu-command/src/commands/url_/host.rs b/crates/nu-command/src/commands/url_/host.rs index ea519e9210bd..97512ccc85fe 100644 --- a/crates/nu-command/src/commands/url_/host.rs +++ b/crates/nu-command/src/commands/url_/host.rs @@ -22,7 +22,7 @@ impl WholeStreamCommand for UrlHost { "gets the host of a url" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let (DefaultArguments { rest }, input) = args.process()?; Ok(operate(input, rest, &host)) } diff --git a/crates/nu-command/src/commands/url_/mod.rs b/crates/nu-command/src/commands/url_/mod.rs index 0fd546259876..9e14370b8536 100644 --- a/crates/nu-command/src/commands/url_/mod.rs +++ b/crates/nu-command/src/commands/url_/mod.rs @@ -42,7 +42,7 @@ where Ok(v) } -fn operate(input: crate::InputStream, paths: Vec, action: &'static F) -> OutputStream +fn operate(input: crate::InputStream, paths: Vec, action: &'static F) -> ActionStream where F: Fn(&Url) -> &str + Send + Sync + 'static, { @@ -63,5 +63,5 @@ where ReturnSuccess::value(ret) } }) - .to_output_stream() + .to_output_stream_with_actions() } diff --git a/crates/nu-command/src/commands/url_/path.rs b/crates/nu-command/src/commands/url_/path.rs index d9ca82d5d615..fc999b4e539d 100644 --- a/crates/nu-command/src/commands/url_/path.rs +++ b/crates/nu-command/src/commands/url_/path.rs @@ -22,7 +22,7 @@ impl WholeStreamCommand for UrlPath { "gets the path of a url" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let (DefaultArguments { rest }, input) = args.process()?; Ok(operate(input, rest, &Url::path)) } diff --git a/crates/nu-command/src/commands/url_/query.rs b/crates/nu-command/src/commands/url_/query.rs index 05e256236eca..7700c24141bd 100644 --- a/crates/nu-command/src/commands/url_/query.rs +++ b/crates/nu-command/src/commands/url_/query.rs @@ -22,7 +22,7 @@ impl WholeStreamCommand for UrlQuery { "gets the query of a url" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let (DefaultArguments { rest }, input) = args.process()?; Ok(operate(input, rest, &query)) } diff --git a/crates/nu-command/src/commands/url_/scheme.rs b/crates/nu-command/src/commands/url_/scheme.rs index 4ff31d72bda2..530517c2a7dc 100644 --- a/crates/nu-command/src/commands/url_/scheme.rs +++ b/crates/nu-command/src/commands/url_/scheme.rs @@ -21,7 +21,7 @@ impl WholeStreamCommand for UrlScheme { "gets the scheme (eg http, file) of a url" } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let (DefaultArguments { rest }, input) = args.process()?; Ok(operate(input, rest, &Url::scheme)) } diff --git a/crates/nu-command/src/commands/version.rs b/crates/nu-command/src/commands/version.rs index a913ed81e260..4aadc3cbc0ac 100644 --- a/crates/nu-command/src/commands/version.rs +++ b/crates/nu-command/src/commands/version.rs @@ -23,7 +23,7 @@ impl WholeStreamCommand for Version { "Display Nu version." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { version(args) } @@ -36,7 +36,7 @@ impl WholeStreamCommand for Version { } } -pub fn version(args: CommandArgs) -> Result { +pub fn version(args: CommandArgs) -> Result { let tag = args.call_info.args.span; let mut indexmap = IndexMap::with_capacity(4); @@ -141,7 +141,7 @@ pub fn version(args: CommandArgs) -> Result { ); let value = UntaggedValue::Row(Dictionary::from(indexmap)).into_value(&tag); - Ok(OutputStream::one(value)) + Ok(ActionStream::one(value)) } fn features_enabled() -> Vec { diff --git a/crates/nu-command/src/commands/where_.rs b/crates/nu-command/src/commands/where_.rs index b1d6c6075c4a..69eb0f7ae67e 100644 --- a/crates/nu-command/src/commands/where_.rs +++ b/crates/nu-command/src/commands/where_.rs @@ -30,7 +30,7 @@ impl WholeStreamCommand for Command { "Filter table to match the condition." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { where_command(args) } @@ -59,7 +59,7 @@ impl WholeStreamCommand for Command { ] } } -fn where_command(raw_args: CommandArgs) -> Result { +fn where_command(raw_args: CommandArgs) -> Result { let ctx = Arc::new(EvaluationContext::from_args(&raw_args)); let tag = raw_args.call_info.name_tag.clone(); let (Arguments { block }, input) = raw_args.process()?; @@ -119,7 +119,7 @@ fn where_command(raw_args: CommandArgs) -> Result { Err(e) => Some(Err(e)), } }) - .to_output_stream()) + .to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/which_.rs b/crates/nu-command/src/commands/which_.rs index 176dd7c0a11e..33af7d6d5ef2 100644 --- a/crates/nu-command/src/commands/which_.rs +++ b/crates/nu-command/src/commands/which_.rs @@ -24,7 +24,7 @@ impl WholeStreamCommand for Which { "Finds a program file, alias or custom command." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { which(args) } } @@ -214,7 +214,7 @@ fn which_single(application: Tagged, all: bool, scope: &Scope) -> Vec Result { +fn which(args: CommandArgs) -> Result { let scope = args.scope.clone(); let ( @@ -233,7 +233,7 @@ fn which(args: CommandArgs) -> Result { output.extend(values); } - Ok((output.into_iter().map(ReturnSuccess::value)).to_output_stream()) + Ok((output.into_iter().map(ReturnSuccess::value)).to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/with_env.rs b/crates/nu-command/src/commands/with_env.rs index 98bf4d1f0b13..e02ab29d4d07 100644 --- a/crates/nu-command/src/commands/with_env.rs +++ b/crates/nu-command/src/commands/with_env.rs @@ -37,7 +37,7 @@ impl WholeStreamCommand for WithEnv { "Runs a block with an environment variable set." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { with_env(args) } @@ -67,7 +67,7 @@ impl WholeStreamCommand for WithEnv { } } -fn with_env(raw_args: CommandArgs) -> Result { +fn with_env(raw_args: CommandArgs) -> Result { let redirection = raw_args.call_info.args.external_redirection; let context = EvaluationContext::from_args(&raw_args); let ( @@ -121,7 +121,7 @@ fn with_env(raw_args: CommandArgs) -> Result { let result = run_block(&block.block, &context, input); context.scope.exit_scope(); - result.map(|x| x.to_output_stream()) + result.map(|x| x.to_output_stream_with_actions()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/wrap.rs b/crates/nu-command/src/commands/wrap.rs index fcbf5e9f4708..08d779b2c490 100644 --- a/crates/nu-command/src/commands/wrap.rs +++ b/crates/nu-command/src/commands/wrap.rs @@ -31,7 +31,7 @@ impl WholeStreamCommand for Wrap { "Wraps the given data in a table." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { wrap(args) } @@ -77,7 +77,7 @@ impl WholeStreamCommand for Wrap { } } -fn wrap(args: CommandArgs) -> Result { +fn wrap(args: CommandArgs) -> Result { let (WrapArgs { column }, input) = args.process()?; let mut result_table = vec![]; let mut are_all_rows = true; @@ -119,9 +119,9 @@ fn wrap(args: CommandArgs) -> Result { let row = UntaggedValue::row(index_map).into_untagged_value(); - Ok(OutputStream::one(ReturnSuccess::value(row))) + Ok(ActionStream::one(ReturnSuccess::value(row))) } else { - Ok((result_table.into_iter().map(ReturnSuccess::value)).to_output_stream()) + Ok((result_table.into_iter().map(ReturnSuccess::value)).to_output_stream_with_actions()) } } diff --git a/crates/nu-command/src/examples/double_echo.rs b/crates/nu-command/src/examples/double_echo.rs index 02b0a594e287..32829b354113 100644 --- a/crates/nu-command/src/examples/double_echo.rs +++ b/crates/nu-command/src/examples/double_echo.rs @@ -2,7 +2,7 @@ use nu_errors::ShellError; use nu_engine::{CommandArgs, WholeStreamCommand}; use nu_protocol::{Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value}; -use nu_stream::{OutputStream, ToOutputStream}; +use nu_stream::{ActionStream, ToOutputStreamWithActions}; use serde::Deserialize; @@ -26,7 +26,7 @@ impl WholeStreamCommand for Command { "Mock echo." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let name_tag = args.call_info.name_tag.clone(); let (Arguments { rest }, input) = args.process()?; @@ -40,7 +40,7 @@ impl WholeStreamCommand for Command { let stream = rest.into_iter().map(move |i| { let base_value = base_value.clone(); match i.as_string() { - Ok(s) => OutputStream::one(Ok(ReturnSuccess::Value(Value { + Ok(s) => ActionStream::one(Ok(ReturnSuccess::Value(Value { value: UntaggedValue::Primitive(Primitive::String(s)), tag: base_value.tag, }))), @@ -60,7 +60,8 @@ impl WholeStreamCommand for Command { let subtable = vec![UntaggedValue::Table(values).into_value(base_value.tag())]; - (subtable.into_iter().map(ReturnSuccess::value)).to_output_stream() + (subtable.into_iter().map(ReturnSuccess::value)) + .to_output_stream_with_actions() } else { (table .into_iter() @@ -69,10 +70,10 @@ impl WholeStreamCommand for Command { v }) .map(ReturnSuccess::value)) - .to_output_stream() + .to_output_stream_with_actions() } } - _ => OutputStream::one(Ok(ReturnSuccess::Value(Value { + _ => ActionStream::one(Ok(ReturnSuccess::Value(Value { value: i.value.clone(), tag: base_value.tag, }))), @@ -80,6 +81,6 @@ impl WholeStreamCommand for Command { } }); - Ok((stream).flatten().to_output_stream()) + Ok((stream).flatten().to_output_stream_with_actions()) } } diff --git a/crates/nu-command/src/examples/double_ls.rs b/crates/nu-command/src/examples/double_ls.rs index 256d04f06fd9..475bf2002838 100644 --- a/crates/nu-command/src/examples/double_ls.rs +++ b/crates/nu-command/src/examples/double_ls.rs @@ -3,7 +3,7 @@ use crate::examples::sample::ls::file_listing; use nu_engine::{CommandArgs, WholeStreamCommand}; use nu_errors::ShellError; use nu_protocol::{ReturnSuccess, Signature, UntaggedValue, Value}; -use nu_stream::{OutputStream, ToOutputStream}; +use nu_stream::{ActionStream, ToOutputStreamWithActions}; pub struct Command; @@ -20,7 +20,7 @@ impl WholeStreamCommand for Command { "Mock ls." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let name_tag = args.call_info.name_tag.clone(); let mut base_value = @@ -40,6 +40,6 @@ impl WholeStreamCommand for Command { .collect::>() .into_iter() .map(ReturnSuccess::value)) - .to_output_stream()) + .to_output_stream_with_actions()) } } diff --git a/crates/nu-command/src/examples/stub_generate.rs b/crates/nu-command/src/examples/stub_generate.rs index abbe847f37c2..9572dc03d9dd 100644 --- a/crates/nu-command/src/examples/stub_generate.rs +++ b/crates/nu-command/src/examples/stub_generate.rs @@ -2,7 +2,7 @@ use nu_engine::{CommandArgs, WholeStreamCommand}; use nu_errors::ShellError; use nu_protocol::{ReturnSuccess, Signature, UntaggedValue, Value}; use nu_source::{AnchorLocation, Tag}; -use nu_stream::OutputStream; +use nu_stream::ActionStream; use serde::Deserialize; @@ -26,7 +26,7 @@ impl WholeStreamCommand for Command { "Generates tables and metadata that mimics behavior of real commands in controlled ways." } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { let name_tag = args.call_info.name_tag.clone(); let (Arguments { path: mocked_path }, _input) = args.process()?; @@ -34,7 +34,7 @@ impl WholeStreamCommand for Command { let out = UntaggedValue::string("Yehuda Katz in Ecuador"); if let Some(true) = mocked_path { - Ok(OutputStream::one(Ok(ReturnSuccess::Value(Value { + Ok(ActionStream::one(Ok(ReturnSuccess::Value(Value { value: out, tag: Tag { anchor: Some(mock_path()), @@ -42,7 +42,7 @@ impl WholeStreamCommand for Command { }, })))) } else { - Ok(OutputStream::one(Ok(ReturnSuccess::Value( + Ok(ActionStream::one(Ok(ReturnSuccess::Value( out.into_value(name_tag), )))) } diff --git a/crates/nu-command/src/lib.rs b/crates/nu-command/src/lib.rs index 0b491777cbdb..c3cf4f46a7ae 100644 --- a/crates/nu-command/src/lib.rs +++ b/crates/nu-command/src/lib.rs @@ -16,7 +16,7 @@ pub use nu_data::config; pub use nu_data::dict::TaggedListBuilder; pub use nu_data::primitive; pub use nu_data::value; -pub use nu_stream::{InputStream, InterruptibleStream, OutputStream}; +pub use nu_stream::{ActionStream, InputStream, InterruptibleStream}; pub use nu_value_ext::ValueExt; pub use num_traits::cast::ToPrimitive; diff --git a/crates/nu-command/src/prelude.rs b/crates/nu-command/src/prelude.rs index faa34ef0021e..83f226a51d4a 100644 --- a/crates/nu-command/src/prelude.rs +++ b/crates/nu-command/src/prelude.rs @@ -22,8 +22,8 @@ pub(crate) use nu_engine::{RunnableContext, RunnableContextWithoutInput}; pub(crate) use nu_parser::ParserScope; pub(crate) use nu_protocol::{out, row}; pub(crate) use nu_source::{AnchorLocation, PrettyDebug, Span, SpannedItem, Tag, TaggedItem}; -pub(crate) use nu_stream::ToInputStream; -pub(crate) use nu_stream::{InputStream, Interruptible, OutputStream}; +pub(crate) use nu_stream::{ActionStream, InputStream, Interruptible, OutputStream}; +pub(crate) use nu_stream::{ToInputStream, ToOutputStream, ToOutputStreamWithActions}; pub(crate) use nu_value_ext::ValueExt; pub(crate) use num_bigint::BigInt; pub(crate) use num_traits::cast::ToPrimitive; @@ -34,33 +34,48 @@ pub(crate) use std::sync::Arc; #[allow(clippy::wrong_self_convention)] pub trait FromInputStream { - fn from_input_stream(self) -> OutputStream; + fn from_input_stream(self) -> ActionStream; } impl FromInputStream for T where T: Iterator + Send + Sync + 'static, { - fn from_input_stream(self) -> OutputStream { - OutputStream { + fn from_input_stream(self) -> ActionStream { + ActionStream { values: Box::new(self.map(nu_protocol::ReturnSuccess::value)), } } } -#[allow(clippy::wrong_self_convention)] -pub trait ToOutputStream { - fn to_output_stream(self) -> OutputStream; -} +// #[allow(clippy::wrong_self_convention)] +// pub trait ToOutputStream { +// fn to_output_stream(self) -> OutputStream; +// } -impl ToOutputStream for T -where - T: Iterator + Send + Sync + 'static, - U: Into, -{ - fn to_output_stream(self) -> OutputStream { - OutputStream { - values: Box::new(self.map(|item| item.into())), - } - } -} +// impl ToOutputStream for T +// where +// T: Iterator + Send + Sync + 'static, +// U: Into, +// { +// fn to_output_stream(self) -> OutputStream { +// OutputStream::from_stream(self) +// } +// } + +// #[allow(clippy::wrong_self_convention)] +// pub trait ToOutputStreamWithAction { +// fn to_output_stream_with_actions(self) -> ActionStream; +// } + +// impl ToOutputStreamWithAction for T +// where +// T: Iterator + Send + Sync + 'static, +// U: Into, +// { +// fn to_output_stream_with_actions(self) -> ActionStream { +// ActionStream { +// values: Box::new(self.map(|item| item.into())), +// } +// } +// } diff --git a/crates/nu-engine/src/evaluate/block.rs b/crates/nu-engine/src/evaluate/block.rs index 328cc2b314bb..69e86665125f 100644 --- a/crates/nu-engine/src/evaluate/block.rs +++ b/crates/nu-engine/src/evaluate/block.rs @@ -8,16 +8,16 @@ use nu_protocol::hir::{ }; use nu_protocol::{ReturnSuccess, UntaggedValue, Value}; use nu_source::{Span, Tag}; -use nu_stream::InputStream; -use nu_stream::ToOutputStream; +use nu_stream::ToOutputStreamWithActions; +use nu_stream::{InputStream, OutputStream}; use std::sync::atomic::Ordering; pub fn run_block( block: &Block, ctx: &EvaluationContext, mut input: InputStream, -) -> Result { - let mut output: Result = Ok(InputStream::empty()); +) -> Result { + let mut output: Result = Ok(OutputStream::empty()); for (_, definition) in block.definitions.iter() { ctx.scope.add_definition(definition.clone()); } @@ -47,13 +47,13 @@ pub fn run_block( } }; match output_stream.next() { - Some(Ok(ReturnSuccess::Value(Value { + Some(Value { value: UntaggedValue::Error(e), .. - }))) => { + }) => { return Err(e); } - Some(Ok(_item)) => { + Some(_item) => { if let Some(err) = ctx.get_errors().get(0) { ctx.clear_errors(); return Err(err.clone()); @@ -68,9 +68,6 @@ pub fn run_block( return Err(err.clone()); } } - Some(Err(e)) => { - return Err(e); - } } } } @@ -78,12 +75,12 @@ pub fn run_block( return Err(e); } } - output = Ok(InputStream::empty()); + output = Ok(OutputStream::empty()); for pipeline in &group.pipelines { match output { Ok(inp) if inp.is_empty() => {} Ok(inp) => { - let mut output_stream = inp.to_output_stream(); + let mut output_stream = inp.to_output_stream_with_actions(); match output_stream.next() { Some(Ok(ReturnSuccess::Value(Value { @@ -123,7 +120,7 @@ pub fn run_block( } output = run_pipeline(pipeline, ctx, input); - input = InputStream::empty(); + input = OutputStream::empty(); } } @@ -134,7 +131,7 @@ fn run_pipeline( commands: &Pipeline, ctx: &EvaluationContext, mut input: InputStream, -) -> Result { +) -> Result { for item in commands.list.clone() { input = match item { ClassifiedCommand::Dynamic(call) => { diff --git a/crates/nu-engine/src/evaluate/internal.rs b/crates/nu-engine/src/evaluate/internal.rs index 66ff7c9d4967..02c387e00b7f 100644 --- a/crates/nu-engine/src/evaluate/internal.rs +++ b/crates/nu-engine/src/evaluate/internal.rs @@ -5,10 +5,12 @@ use crate::filesystem::filesystem_shell::{FilesystemShell, FilesystemShellMode}; use crate::shell::value_shell::ValueShell; use log::{log_enabled, trace}; use nu_errors::ShellError; -use nu_protocol::hir::{ExternalRedirection, InternalCommand}; +use nu_protocol::hir::{ + Expression, ExternalRedirection, InternalCommand, SpannedExpression, Synthetic, +}; use nu_protocol::{CommandAction, ReturnSuccess, UntaggedValue, Value}; use nu_source::{PrettyDebug, Span, Tag}; -use nu_stream::{InputStream, OutputStream}; +use nu_stream::{ActionStream, InputStream}; pub(crate) fn run_internal_command( command: InternalCommand, @@ -23,39 +25,52 @@ pub(crate) fn run_internal_command( let objects: InputStream = input; let internal_command = context.scope.expect_command(&command.name); - - let result = { - context.run_command( - internal_command?, - Tag::unknown_anchor(command.name_span), - command.args.clone(), - objects, - )? - }; - - Ok(InputStream::from_stream(InternalIterator { - command, + let internal_command = internal_command?; + + let result = context.run_command( + internal_command, + Tag::unknown_anchor(command.name_span), + command.args, + objects, + )?; + Ok(InputStream::from_stream(InternalIteratorSimple { context: context.clone(), - leftovers: vec![], input: result, })) } -struct InternalIterator { +struct InternalIteratorSimple { context: EvaluationContext, - command: InternalCommand, - leftovers: Vec, - input: OutputStream, + input: InputStream, } -impl Iterator for InternalIterator { +impl Iterator for InternalIteratorSimple { type Item = Value; fn next(&mut self) -> Option { - // let head = Arc::new(command.args.head.clone()); - // let context = context.clone(); - // let command = Arc::new(command); + match self.input.next() { + Some(Value { + value: UntaggedValue::Error(err), + .. + }) => { + self.context.error(err); + None + } + x => x, + } + } +} + +pub struct InternalIterator { + pub context: EvaluationContext, + pub leftovers: Vec, + pub input: ActionStream, +} +impl Iterator for InternalIterator { + type Item = Value; + + fn next(&mut self) -> Option { if !self.leftovers.is_empty() { let output = self.leftovers.remove(0); return Some(output); @@ -84,17 +99,23 @@ impl Iterator for InternalIterator { shell_manager: self.context.shell_manager.clone(), call_info: UnevaluatedCallInfo { args: nu_protocol::hir::Call { - head: self.command.args.head.clone(), + head: Box::new(SpannedExpression { + expr: Expression::Synthetic(Synthetic::String( + command_name.clone(), + )), + span: tagged_contents.tag().span, + }), positional: None, named: None, span: Span::unknown(), external_redirection: ExternalRedirection::Stdout, }, - name_tag: Tag::unknown_anchor(self.command.name_span), + name_tag: tagged_contents.tag(), }, scope: self.context.scope.clone(), }; - let result = converter.run(new_args.with_input(vec![tagged_contents])); + let result = converter + .run_with_actions(new_args.with_input(vec![tagged_contents])); match result { Ok(mut result) => { diff --git a/crates/nu-engine/src/evaluation_context.rs b/crates/nu-engine/src/evaluation_context.rs index e4c524aacf4a..ea6283378bbe 100644 --- a/crates/nu-engine/src/evaluation_context.rs +++ b/crates/nu-engine/src/evaluation_context.rs @@ -9,7 +9,7 @@ use nu_data::config::{self, Conf, NuConfig}; use nu_errors::ShellError; use nu_protocol::{hir, ConfigPath}; use nu_source::{Span, Tag}; -use nu_stream::{InputStream, OutputStream}; +use nu_stream::InputStream; use parking_lot::Mutex; use std::sync::atomic::AtomicBool; use std::{path::Path, sync::Arc}; @@ -113,7 +113,7 @@ impl EvaluationContext { name_tag: Tag, args: hir::Call, input: InputStream, - ) -> Result { + ) -> Result { let command_args = self.command_args(args, input, name_tag); command.run(command_args) } diff --git a/crates/nu-engine/src/filesystem/filesystem_shell.rs b/crates/nu-engine/src/filesystem/filesystem_shell.rs index 3672aa2382e0..8892cdc2d8e3 100644 --- a/crates/nu-engine/src/filesystem/filesystem_shell.rs +++ b/crates/nu-engine/src/filesystem/filesystem_shell.rs @@ -9,7 +9,7 @@ use encoding_rs::Encoding; use nu_data::config::LocalConfigDiff; use nu_protocol::{CommandAction, ConfigPath, TaggedDictBuilder, Value}; use nu_source::{Span, Tag}; -use nu_stream::{Interruptible, OutputStream, ToOutputStream}; +use nu_stream::{ActionStream, Interruptible, ToOutputStreamWithActions}; use std::collections::VecDeque; use std::io::{Error, ErrorKind}; use std::path::{Path, PathBuf}; @@ -118,7 +118,7 @@ impl Shell for FilesystemShell { }: LsArgs, name_tag: Tag, ctrl_c: Arc, - ) -> Result { + ) -> Result { let ctrl_c_copy = ctrl_c.clone(); let (path, p_tag) = match path { Some(p) => { @@ -146,7 +146,7 @@ impl Shell for FilesystemShell { )); } if is_empty_dir(&p) { - return Ok(OutputStream::empty()); + return Ok(ActionStream::empty()); } p.push("*"); } @@ -154,7 +154,7 @@ impl Shell for FilesystemShell { } None => { if is_empty_dir(&self.path()) { - return Ok(OutputStream::empty()); + return Ok(ActionStream::empty()); } else { (PathBuf::from("./*"), name_tag.clone()) } @@ -222,10 +222,10 @@ impl Shell for FilesystemShell { Some(entry) }) .interruptible(ctrl_c_copy) - .to_output_stream()) + .to_output_stream_with_actions()) } - fn cd(&self, args: CdArgs, name: Tag) -> Result { + fn cd(&self, args: CdArgs, name: Tag) -> Result { let path = match args.path { None => match homedir_if_possible() { Some(o) => o, @@ -342,7 +342,7 @@ impl Shell for FilesystemShell { }: CopyArgs, name: Tag, path: &str, - ) -> Result { + ) -> Result { let name_tag = name; let path = Path::new(path); @@ -467,7 +467,7 @@ impl Shell for FilesystemShell { } } - Ok(OutputStream::empty()) + Ok(ActionStream::empty()) } fn mkdir( @@ -478,7 +478,7 @@ impl Shell for FilesystemShell { }: MkdirArgs, name: Tag, path: &str, - ) -> Result { + ) -> Result { let path = Path::new(path); let mut stream = VecDeque::new(); @@ -515,7 +515,7 @@ impl Shell for FilesystemShell { MvArgs { src, dst }: MvArgs, _name: Tag, path: &str, - ) -> Result { + ) -> Result { let path = Path::new(path); let source = path.join(&src.item); let destination = path.join(&dst.item); @@ -583,7 +583,7 @@ impl Shell for FilesystemShell { } } - Ok(OutputStream::empty()) + Ok(ActionStream::empty()) } fn rm( @@ -597,7 +597,7 @@ impl Shell for FilesystemShell { }: RemoveArgs, name: Tag, path: &str, - ) -> Result { + ) -> Result { let rm_always_trash = nu_data::config::config(Tag::unknown())? .get("rm_always_trash") .map(|val| val.is_true()) @@ -758,14 +758,14 @@ impl Shell for FilesystemShell { )) } }) - .to_output_stream()) + .to_output_stream_with_actions()) } fn path(&self) -> String { self.path.clone() } - fn pwd(&self, args: EvaluatedWholeStreamCommandArgs) -> Result { + fn pwd(&self, args: EvaluatedWholeStreamCommandArgs) -> Result { let path = PathBuf::from(self.path()); let p = match dunce::canonicalize(path.as_path()) { Ok(p) => p, @@ -778,7 +778,7 @@ impl Shell for FilesystemShell { } }; - Ok(OutputStream::one(ReturnSuccess::value( + Ok(ActionStream::one(ReturnSuccess::value( UntaggedValue::Primitive(Primitive::String(p.to_string_lossy().to_string())) .into_value(&args.call_info.name_tag), ))) @@ -860,9 +860,9 @@ impl Shell for FilesystemShell { full_path: &Path, save_data: &[u8], name: Span, - ) -> Result { + ) -> Result { match std::fs::write(full_path, save_data) { - Ok(_) => Ok(OutputStream::empty()), + Ok(_) => Ok(ActionStream::empty()), Err(e) => Err(ShellError::labeled_error( e.to_string(), "IO error while saving", diff --git a/crates/nu-engine/src/plugin/run_plugin.rs b/crates/nu-engine/src/plugin/run_plugin.rs index 2ebbf38741c0..d8f4569d8a81 100644 --- a/crates/nu-engine/src/plugin/run_plugin.rs +++ b/crates/nu-engine/src/plugin/run_plugin.rs @@ -6,7 +6,7 @@ use log::trace; use nu_errors::ShellError; use nu_plugin::jsonrpc::JsonRpc; use nu_protocol::{Primitive, ReturnValue, Signature, UntaggedValue, Value}; -use nu_stream::{OutputStream, ToOutputStream}; +use nu_stream::{ActionStream, ToOutputStreamWithActions}; use serde::{self, Deserialize, Serialize}; use std::collections::VecDeque; use std::io::prelude::*; @@ -106,12 +106,12 @@ impl WholeStreamCommand for PluginFilter { &self.config.usage } - fn run(&self, args: CommandArgs) -> Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { run_filter(self.path.clone(), args) } } -fn run_filter(path: String, args: CommandArgs) -> Result { +fn run_filter(path: String, args: CommandArgs) -> Result { trace!("filter_plugin :: {}", path); let bos = vec![UntaggedValue::Primitive(Primitive::BeginningOfStream).into_untagged_value()] @@ -175,7 +175,7 @@ fn run_filter(path: String, args: CommandArgs) -> Result { - return OutputStream::one(Err(ShellError::labeled_error( + return ActionStream::one(Err(ShellError::labeled_error( "Could not load json from plugin", "could not load json from plugin", &call_info.name_tag, @@ -185,7 +185,7 @@ fn run_filter(path: String, args: CommandArgs) -> Result {} Err(err) => { - return OutputStream::one(Err(ShellError::unexpected( + return ActionStream::one(Err(ShellError::unexpected( format!("{}", err), ))); } @@ -201,13 +201,15 @@ fn run_filter(path: String, args: CommandArgs) -> Result match params { - Ok(params) => params.into_iter().to_output_stream(), - Err(e) => { - vec![ReturnValue::Err(e)].into_iter().to_output_stream() + Ok(params) => { + params.into_iter().to_output_stream_with_actions() } + Err(e) => vec![ReturnValue::Err(e)] + .into_iter() + .to_output_stream_with_actions(), }, - Err(e) => OutputStream::one(Err( + Err(e) => ActionStream::one(Err( ShellError::untagged_runtime_error(format!( "Error while processing begin_filter response: {:?} {}", e, input @@ -215,7 +217,7 @@ fn run_filter(path: String, args: CommandArgs) -> Result OutputStream::one(Err(ShellError::untagged_runtime_error( + Err(e) => ActionStream::one(Err(ShellError::untagged_runtime_error( format!("Error while reading begin_filter response: {:?}", e), ))), } @@ -236,7 +238,7 @@ fn run_filter(path: String, args: CommandArgs) -> Result { - return OutputStream::one(Err(ShellError::labeled_error( + return ActionStream::one(Err(ShellError::labeled_error( "Could not load json from plugin", "could not load json from plugin", &call_info.name_tag, @@ -246,7 +248,7 @@ fn run_filter(path: String, args: CommandArgs) -> Result {} Err(err) => { - return OutputStream::one(Err(ShellError::unexpected( + return ActionStream::one(Err(ShellError::unexpected( format!("{}", err), ))); } @@ -262,17 +264,19 @@ fn run_filter(path: String, args: CommandArgs) -> Result match params { - Ok(params) => params.into_iter().to_output_stream(), - Err(e) => { - vec![ReturnValue::Err(e)].into_iter().to_output_stream() + Ok(params) => { + params.into_iter().to_output_stream_with_actions() } + Err(e) => vec![ReturnValue::Err(e)] + .into_iter() + .to_output_stream_with_actions(), }, Err(e) => vec![Err(ShellError::untagged_runtime_error(format!( "Error while processing end_filter response: {:?} {}", e, input )))] .into_iter() - .to_output_stream(), + .to_output_stream_with_actions(), } } Err(e) => vec![Err(ShellError::untagged_runtime_error(format!( @@ -280,7 +284,7 @@ fn run_filter(path: String, args: CommandArgs) -> Result Result { - return OutputStream::one(Err(ShellError::untagged_runtime_error( + return ActionStream::one(Err(ShellError::untagged_runtime_error( format!("Error while processing quit response: {:?}", e), ))); } @@ -322,7 +326,7 @@ fn run_filter(path: String, args: CommandArgs) -> Result { - return OutputStream::one(Err(ShellError::untagged_runtime_error( + return ActionStream::one(Err(ShellError::untagged_runtime_error( format!("Error while processing filter response: {:?}", e), ))); } @@ -336,12 +340,14 @@ fn run_filter(path: String, args: CommandArgs) -> Result match params { - Ok(params) => params.into_iter().to_output_stream(), - Err(e) => { - vec![ReturnValue::Err(e)].into_iter().to_output_stream() + Ok(params) => { + params.into_iter().to_output_stream_with_actions() } + Err(e) => vec![ReturnValue::Err(e)] + .into_iter() + .to_output_stream_with_actions(), }, - Err(e) => OutputStream::one(Err( + Err(e) => ActionStream::one(Err( ShellError::untagged_runtime_error(format!( "Error while processing filter response: {:?}\n== input ==\n{}", e, input @@ -349,7 +355,7 @@ fn run_filter(path: String, args: CommandArgs) -> Result OutputStream::one(Err(ShellError::untagged_runtime_error( + Err(e) => ActionStream::one(Err(ShellError::untagged_runtime_error( format!("Error while reading filter response: {:?}", e), ))), } @@ -357,7 +363,7 @@ fn run_filter(path: String, args: CommandArgs) -> Result Result { + fn run_with_actions(&self, args: CommandArgs) -> Result { run_sink(self.path.clone(), args) } } -fn run_sink(path: String, args: CommandArgs) -> Result { +fn run_sink(path: String, args: CommandArgs) -> Result { let args = args.evaluate_once()?; let call_info = args.call_info.clone(); @@ -429,7 +435,7 @@ fn run_sink(path: String, args: CommandArgs) -> Result if let Ok(mut child) = child { let _ = child.wait(); - Ok(OutputStream::empty()) + Ok(ActionStream::empty()) } else { Err(ShellError::untagged_runtime_error( "Could not create process for sink command", diff --git a/crates/nu-engine/src/script.rs b/crates/nu-engine/src/script.rs index 7999c59b2265..e9c39edc4dca 100644 --- a/crates/nu-engine/src/script.rs +++ b/crates/nu-engine/src/script.rs @@ -5,7 +5,7 @@ use nu_protocol::hir::{ Call, ClassifiedCommand, Expression, InternalCommand, Literal, NamedArguments, SpannedExpression, }; -use nu_protocol::{Primitive, ReturnSuccess, UntaggedValue, Value}; +use nu_protocol::{Primitive, UntaggedValue, Value}; use nu_stream::{InputStream, ToInputStream}; use crate::EvaluationContext; @@ -210,17 +210,16 @@ pub fn process_script( ) { loop { match output_stream.next() { - Some(Ok(ReturnSuccess::Value(Value { + Some(Value { value: UntaggedValue::Error(e), .. - }))) => return LineResult::Error(line.to_string(), e), - Some(Ok(_item)) => { + }) => return LineResult::Error(line.to_string(), e), + Some(_item) => { if ctx.ctrl_c.load(Ordering::SeqCst) { break; } } None => break, - Some(Err(e)) => return LineResult::Error(line.to_string(), e), } } } diff --git a/crates/nu-engine/src/shell/mod.rs b/crates/nu-engine/src/shell/mod.rs index fb2e631d0fdb..be4b20a373de 100644 --- a/crates/nu-engine/src/shell/mod.rs +++ b/crates/nu-engine/src/shell/mod.rs @@ -1,4 +1,4 @@ -use nu_stream::OutputStream; +use nu_stream::ActionStream; use crate::command_args::EvaluatedWholeStreamCommandArgs; use crate::maybe_text_codec::StringOrBinary; @@ -26,14 +26,14 @@ pub trait Shell: std::fmt::Debug { args: LsArgs, name: Tag, ctrl_c: Arc, - ) -> Result; - fn cd(&self, args: CdArgs, name: Tag) -> Result; - fn cp(&self, args: CopyArgs, name: Tag, path: &str) -> Result; - fn mkdir(&self, args: MkdirArgs, name: Tag, path: &str) -> Result; - fn mv(&self, args: MvArgs, name: Tag, path: &str) -> Result; - fn rm(&self, args: RemoveArgs, name: Tag, path: &str) -> Result; + ) -> Result; + fn cd(&self, args: CdArgs, name: Tag) -> Result; + fn cp(&self, args: CopyArgs, name: Tag, path: &str) -> Result; + fn mkdir(&self, args: MkdirArgs, name: Tag, path: &str) -> Result; + fn mv(&self, args: MvArgs, name: Tag, path: &str) -> Result; + fn rm(&self, args: RemoveArgs, name: Tag, path: &str) -> Result; fn path(&self) -> String; - fn pwd(&self, args: EvaluatedWholeStreamCommandArgs) -> Result; + fn pwd(&self, args: EvaluatedWholeStreamCommandArgs) -> Result; fn set_path(&mut self, path: String); fn open( &self, @@ -49,5 +49,5 @@ pub trait Shell: std::fmt::Debug { path: &Path, contents: &[u8], name: Span, - ) -> Result; + ) -> Result; } diff --git a/crates/nu-engine/src/shell/shell_manager.rs b/crates/nu-engine/src/shell/shell_manager.rs index e6f68dc955d9..d0bdf5b42763 100644 --- a/crates/nu-engine/src/shell/shell_manager.rs +++ b/crates/nu-engine/src/shell/shell_manager.rs @@ -1,7 +1,7 @@ use crate::shell::Shell; use crate::{command_args::EvaluatedWholeStreamCommandArgs, FilesystemShell}; use crate::{filesystem::filesystem_shell::FilesystemShellMode, maybe_text_codec::StringOrBinary}; -use nu_stream::OutputStream; +use nu_stream::ActionStream; use crate::shell::shell_args::{CdArgs, CopyArgs, LsArgs, MkdirArgs, MvArgs, RemoveArgs}; use encoding_rs::Encoding; @@ -69,7 +69,7 @@ impl ShellManager { self.shells.lock()[self.current_shell()].path() } - pub fn pwd(&self, args: EvaluatedWholeStreamCommandArgs) -> Result { + pub fn pwd(&self, args: EvaluatedWholeStreamCommandArgs) -> Result { let env = self.shells.lock(); env[self.current_shell()].pwd(args) @@ -96,7 +96,7 @@ impl ShellManager { full_path: &Path, save_data: &[u8], name: Span, - ) -> Result { + ) -> Result { self.shells.lock()[self.current_shell()].save(full_path, save_data, name) } @@ -137,40 +137,40 @@ impl ShellManager { args: LsArgs, name: Tag, ctrl_c: Arc, - ) -> Result { + ) -> Result { let env = self.shells.lock(); env[self.current_shell()].ls(args, name, ctrl_c) } - pub fn cd(&self, args: CdArgs, name: Tag) -> Result { + pub fn cd(&self, args: CdArgs, name: Tag) -> Result { let env = self.shells.lock(); env[self.current_shell()].cd(args, name) } - pub fn cp(&self, args: CopyArgs, name: Tag) -> Result { + pub fn cp(&self, args: CopyArgs, name: Tag) -> Result { let shells = self.shells.lock(); let path = shells[self.current_shell()].path(); shells[self.current_shell()].cp(args, name, &path) } - pub fn rm(&self, args: RemoveArgs, name: Tag) -> Result { + pub fn rm(&self, args: RemoveArgs, name: Tag) -> Result { let shells = self.shells.lock(); let path = shells[self.current_shell()].path(); shells[self.current_shell()].rm(args, name, &path) } - pub fn mkdir(&self, args: MkdirArgs, name: Tag) -> Result { + pub fn mkdir(&self, args: MkdirArgs, name: Tag) -> Result { let shells = self.shells.lock(); let path = shells[self.current_shell()].path(); shells[self.current_shell()].mkdir(args, name, &path) } - pub fn mv(&self, args: MvArgs, name: Tag) -> Result { + pub fn mv(&self, args: MvArgs, name: Tag) -> Result { let shells = self.shells.lock(); let path = shells[self.current_shell()].path(); diff --git a/crates/nu-engine/src/shell/value_shell.rs b/crates/nu-engine/src/shell/value_shell.rs index e58f59ad8411..6438ace98b5a 100644 --- a/crates/nu-engine/src/shell/value_shell.rs +++ b/crates/nu-engine/src/shell/value_shell.rs @@ -8,7 +8,7 @@ use nu_protocol::ValueStructure; use nu_protocol::{ReturnSuccess, ShellTypeName, UntaggedValue, Value}; use nu_source::SpannedItem; use nu_source::{Span, Tag, Tagged}; -use nu_stream::OutputStream; +use nu_stream::ActionStream; use nu_value_ext::ValueExt; use std::collections::VecDeque; use std::ffi::OsStr; @@ -99,7 +99,7 @@ impl Shell for ValueShell { LsArgs { path, .. }: LsArgs, name_tag: Tag, _ctrl_c: Arc, - ) -> Result { + ) -> Result { let mut full_path = PathBuf::from(self.path()); if let Some(value) = &path { @@ -133,7 +133,7 @@ impl Shell for ValueShell { Ok(output.into()) } - fn cd(&self, args: CdArgs, name: Tag) -> Result { + fn cd(&self, args: CdArgs, name: Tag) -> Result { let destination = args.path; let path = match destination { @@ -178,10 +178,10 @@ impl Shell for ValueShell { )); } - Ok(OutputStream::one(ReturnSuccess::change_cwd(path))) + Ok(ActionStream::one(ReturnSuccess::change_cwd(path))) } - fn cp(&self, _args: CopyArgs, name: Tag, _path: &str) -> Result { + fn cp(&self, _args: CopyArgs, name: Tag, _path: &str) -> Result { Err(ShellError::labeled_error( "cp not currently supported on values", "not currently supported", @@ -189,7 +189,7 @@ impl Shell for ValueShell { )) } - fn mv(&self, _args: MvArgs, name: Tag, _path: &str) -> Result { + fn mv(&self, _args: MvArgs, name: Tag, _path: &str) -> Result { Err(ShellError::labeled_error( "mv not currently supported on values", "not currently supported", @@ -197,7 +197,7 @@ impl Shell for ValueShell { )) } - fn mkdir(&self, _args: MkdirArgs, name: Tag, _path: &str) -> Result { + fn mkdir(&self, _args: MkdirArgs, name: Tag, _path: &str) -> Result { Err(ShellError::labeled_error( "mkdir not currently supported on values", "not currently supported", @@ -205,7 +205,7 @@ impl Shell for ValueShell { )) } - fn rm(&self, _args: RemoveArgs, name: Tag, _path: &str) -> Result { + fn rm(&self, _args: RemoveArgs, name: Tag, _path: &str) -> Result { Err(ShellError::labeled_error( "rm not currently supported on values", "not currently supported", @@ -217,8 +217,8 @@ impl Shell for ValueShell { self.path.clone() } - fn pwd(&self, args: EvaluatedWholeStreamCommandArgs) -> Result { - Ok(OutputStream::one( + fn pwd(&self, args: EvaluatedWholeStreamCommandArgs) -> Result { + Ok(ActionStream::one( UntaggedValue::string(self.path()).into_value(&args.call_info.name_tag), )) } @@ -247,7 +247,7 @@ impl Shell for ValueShell { _path: &Path, _contents: &[u8], _name: Span, - ) -> Result { + ) -> Result { Err(ShellError::unimplemented( "save on help shell is not supported", )) diff --git a/crates/nu-engine/src/whole_stream_command.rs b/crates/nu-engine/src/whole_stream_command.rs index 873176b1678b..20f1430aacdd 100644 --- a/crates/nu-engine/src/whole_stream_command.rs +++ b/crates/nu-engine/src/whole_stream_command.rs @@ -8,7 +8,7 @@ use nu_parser::ParserScope; use nu_protocol::hir::Block; use nu_protocol::{ReturnSuccess, Signature, UntaggedValue}; use nu_source::{DbgDocBldr, DebugDocBuilder, PrettyDebugWithSource, Span, Tag}; -use nu_stream::{OutputStream, ToOutputStream}; +use nu_stream::{ActionStream, InputStream, OutputStream, ToOutputStream}; use std::sync::Arc; pub trait WholeStreamCommand: Send + Sync { @@ -24,7 +24,24 @@ pub trait WholeStreamCommand: Send + Sync { "" } - fn run(&self, args: CommandArgs) -> Result; + fn run_with_actions(&self, _args: CommandArgs) -> Result { + return Err(ShellError::unimplemented(&format!( + "{} does not implement run or run_with_actions", + self.name() + ))); + } + + fn run(&self, args: CommandArgs) -> Result { + let context = EvaluationContext::from_args(&args); + let stream = self.run_with_actions(args)?; + + Ok(Box::new(crate::evaluate::internal::InternalIterator { + context, + input: stream, + leftovers: vec![], + }) + .to_output_stream()) + } fn is_binary(&self) -> bool { false @@ -156,7 +173,7 @@ impl WholeStreamCommand for Arc { } let result = run_block(&block, &ctx, input); ctx.scope.exit_scope(); - result.map(|x| x.to_output_stream()) + result } fn is_binary(&self) -> bool { @@ -211,12 +228,23 @@ impl Command { self.0.examples() } - pub fn run(&self, args: CommandArgs) -> Result { + pub fn run_with_actions(&self, args: CommandArgs) -> Result { if args.call_info.switch_present("help") { let cl = self.0.clone(); - Ok(OutputStream::one(Ok(ReturnSuccess::Value( + Ok(ActionStream::one(Ok(ReturnSuccess::Value( UntaggedValue::string(get_full_help(&*cl, &args.scope)).into_value(Tag::unknown()), )))) + } else { + self.0.run_with_actions(args) + } + } + + pub fn run(&self, args: CommandArgs) -> Result { + if args.call_info.switch_present("help") { + let cl = self.0.clone(); + Ok(InputStream::one( + UntaggedValue::string(get_full_help(&*cl, &args.scope)).into_value(Tag::unknown()), + )) } else { self.0.run(args) } diff --git a/crates/nu-errors/src/lib.rs b/crates/nu-errors/src/lib.rs index 08ee21e41963..1f4fc21f1c98 100644 --- a/crates/nu-errors/src/lib.rs +++ b/crates/nu-errors/src/lib.rs @@ -310,6 +310,10 @@ impl PrettyDebug for ShellError { DbgDocBldr::error("Unknown Error") + DbgDocBldr::delimit("(", DbgDocBldr::description(reason), ")") } + ProximateShellError::Unimplemented { reason } => { + DbgDocBldr::error("Unimplemented") + + DbgDocBldr::delimit("(", DbgDocBldr::description(reason), ")") + } ProximateShellError::ExternalPlaceholderError => { DbgDocBldr::error("non-zero external exit code") } @@ -600,6 +604,7 @@ impl ShellError { } ProximateShellError::UntaggedRuntimeError { reason } => Some(Diagnostic::error().with_message(format!("Error: {}", reason))), + ProximateShellError::Unimplemented { reason } => Some(Diagnostic::error().with_message(format!("Inimplemented: {}", reason))), ProximateShellError::ExternalPlaceholderError => None, } } @@ -636,12 +641,16 @@ impl ShellError { } pub fn unimplemented(title: impl Into) -> ShellError { - ShellError::untagged_runtime_error(&format!("Unimplemented: {}", title.into())) + ShellError::unimplemented(&format!("Unimplemented: {}", title.into())) } pub fn unexpected(title: impl Into) -> ShellError { ShellError::untagged_runtime_error(&format!("Unexpected: {}", title.into())) } + + pub fn is_unimplemented(&self) -> bool { + matches!(self.error, ProximateShellError::Unimplemented { .. }) + } } /// `ExpectedRange` describes a range of values that was expected by a command. In addition @@ -747,6 +756,9 @@ pub enum ProximateShellError { UntaggedRuntimeError { reason: String, }, + Unimplemented { + reason: String, + }, ExternalPlaceholderError, } @@ -779,6 +791,7 @@ impl HasFallibleSpan for ProximateShellError { ProximateShellError::Diagnostic(_) => return None, ProximateShellError::CoerceError { left, right } => left.span.until(right.span), ProximateShellError::UntaggedRuntimeError { .. } => return None, + ProximateShellError::Unimplemented { .. } => return None, ProximateShellError::ExternalPlaceholderError => return None, }) } diff --git a/crates/nu-protocol/src/value.rs b/crates/nu-protocol/src/value.rs index 8e6d494aaa76..79aaae35daa5 100644 --- a/crates/nu-protocol/src/value.rs +++ b/crates/nu-protocol/src/value.rs @@ -309,6 +309,10 @@ impl Value { self.tag.clone() } + pub fn error(e: ShellError) -> Value { + UntaggedValue::Error(e).into_untagged_value() + } + /// View the Value as a string, if possible pub fn as_string(&self) -> Result { match &self.value { diff --git a/crates/nu-stream/src/lib.rs b/crates/nu-stream/src/lib.rs index 2067d2f3a12f..f2e144aca249 100644 --- a/crates/nu-stream/src/lib.rs +++ b/crates/nu-stream/src/lib.rs @@ -8,3 +8,4 @@ pub use input::*; pub use interruptible::*; pub use output::*; pub use prelude::ToOutputStream; +pub use prelude::ToOutputStreamWithActions; diff --git a/crates/nu-stream/src/output.rs b/crates/nu-stream/src/output.rs index 2abc4f817a59..fefd903ae23e 100644 --- a/crates/nu-stream/src/output.rs +++ b/crates/nu-stream/src/output.rs @@ -2,11 +2,13 @@ use crate::prelude::*; use nu_protocol::{ReturnSuccess, ReturnValue, Value}; use std::iter::IntoIterator; -pub struct OutputStream { +pub type OutputStream = InputStream; + +pub struct ActionStream { pub values: Box + Send + Sync>, } -impl Iterator for OutputStream { +impl Iterator for ActionStream { type Item = ReturnValue; fn next(&mut self) -> Option { @@ -14,28 +16,28 @@ impl Iterator for OutputStream { } } -impl OutputStream { - pub fn new(values: impl Iterator + Send + Sync + 'static) -> OutputStream { - OutputStream { +impl ActionStream { + pub fn new(values: impl Iterator + Send + Sync + 'static) -> ActionStream { + ActionStream { values: Box::new(values), } } - pub fn empty() -> OutputStream { - OutputStream { + pub fn empty() -> ActionStream { + ActionStream { values: Box::new(std::iter::empty()), } } - pub fn one(item: impl Into) -> OutputStream { + pub fn one(item: impl Into) -> ActionStream { let item = item.into(); - OutputStream { + ActionStream { values: Box::new(std::iter::once(item)), } } - pub fn from_input(input: impl Iterator + Send + Sync + 'static) -> OutputStream { - OutputStream { + pub fn from_input(input: impl Iterator + Send + Sync + 'static) -> ActionStream { + ActionStream { values: Box::new(input.map(ReturnSuccess::value)), } } @@ -49,9 +51,9 @@ impl OutputStream { } } -impl From for OutputStream { - fn from(input: InputStream) -> OutputStream { - OutputStream { +impl From for ActionStream { + fn from(input: InputStream) -> ActionStream { + ActionStream { values: Box::new(input.into_iter().map(ReturnSuccess::value)), } } @@ -71,35 +73,35 @@ impl From for OutputStream { // } // } -impl From> for OutputStream { - fn from(input: VecDeque) -> OutputStream { - OutputStream { +impl From> for ActionStream { + fn from(input: VecDeque) -> ActionStream { + ActionStream { values: Box::new(input.into_iter()), } } } -impl From> for OutputStream { - fn from(input: VecDeque) -> OutputStream { +impl From> for ActionStream { + fn from(input: VecDeque) -> ActionStream { let stream = input.into_iter().map(ReturnSuccess::value); - OutputStream { + ActionStream { values: Box::new(stream), } } } -impl From> for OutputStream { - fn from(input: Vec) -> OutputStream { - OutputStream { +impl From> for ActionStream { + fn from(input: Vec) -> ActionStream { + ActionStream { values: Box::new(input.into_iter()), } } } -impl From> for OutputStream { - fn from(input: Vec) -> OutputStream { +impl From> for ActionStream { + fn from(input: Vec) -> ActionStream { let stream = input.into_iter().map(ReturnSuccess::value); - OutputStream { + ActionStream { values: Box::new(stream), } } diff --git a/crates/nu-stream/src/prelude.rs b/crates/nu-stream/src/prelude.rs index db62e176bfa4..2bbff10aded5 100644 --- a/crates/nu-stream/src/prelude.rs +++ b/crates/nu-stream/src/prelude.rs @@ -34,20 +34,36 @@ macro_rules! trace_out_stream { pub(crate) use std::collections::VecDeque; pub(crate) use std::sync::Arc; -pub(crate) use crate::{InputStream, OutputStream}; +use nu_protocol::Value; + +pub(crate) use crate::{ActionStream, InputStream, OutputStream}; #[allow(clippy::wrong_self_convention)] pub trait ToOutputStream { fn to_output_stream(self) -> OutputStream; } -impl ToOutputStream for T +impl ToOutputStream for T +where + T: Iterator + Send + Sync + 'static, +{ + fn to_output_stream(self) -> OutputStream { + OutputStream::from_stream(self) + } +} + +#[allow(clippy::wrong_self_convention)] +pub trait ToOutputStreamWithActions { + fn to_output_stream_with_actions(self) -> ActionStream; +} + +impl ToOutputStreamWithActions for T where T: Iterator + Send + Sync + 'static, U: Into, { - fn to_output_stream(self) -> OutputStream { - OutputStream { + fn to_output_stream_with_actions(self) -> ActionStream { + ActionStream { values: Box::new(self.map(|item| item.into())), } } From 3ccbab9ad8c79f8230e213172824864a04671a48 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Mon, 12 Apr 2021 10:20:54 +1200 Subject: [PATCH 2/5] Fmt --- crates/nu-command/src/commands/cal.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/nu-command/src/commands/cal.rs b/crates/nu-command/src/commands/cal.rs index 3c77ec17cf16..8c181dfe7b50 100644 --- a/crates/nu-command/src/commands/cal.rs +++ b/crates/nu-command/src/commands/cal.rs @@ -101,7 +101,9 @@ pub fn cal(args: CommandArgs) -> Result { current_day_option, )?; - Ok(calendar_vec_deque.into_iter().to_output_stream_with_actions()) + Ok(calendar_vec_deque + .into_iter() + .to_output_stream_with_actions()) } fn get_invalid_year_shell_error(year_tag: &Tag) -> ShellError { From 629ce7e40b2ff4831a0e33ee4b2de63ab15474c1 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Mon, 12 Apr 2021 13:07:38 +1200 Subject: [PATCH 3/5] Missed update --- crates/nu-command/src/commands/exec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/nu-command/src/commands/exec.rs b/crates/nu-command/src/commands/exec.rs index e927c148d10c..110dd8ef91b5 100644 --- a/crates/nu-command/src/commands/exec.rs +++ b/crates/nu-command/src/commands/exec.rs @@ -74,7 +74,7 @@ fn exec(args: CommandArgs) -> Result { } #[cfg(not(unix))] -fn exec(args: CommandArgs) -> Result { +fn exec(args: CommandArgs) -> Result { Err(ShellError::labeled_error( "Error on exec", "exec is not supported on your platform", From d39886ba90a56f4a9d25f8a8d659831ad904f89e Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Mon, 12 Apr 2021 13:57:49 +1200 Subject: [PATCH 4/5] Cleanup helper names --- crates/nu-cli/src/prelude.rs | 17 ---------- crates/nu-command/src/commands/all.rs | 4 +-- crates/nu-command/src/commands/ansi/strip.rs | 2 +- crates/nu-command/src/commands/any.rs | 2 +- crates/nu-command/src/commands/append.rs | 2 +- crates/nu-command/src/commands/cal.rs | 2 +- crates/nu-command/src/commands/compact.rs | 2 +- .../nu-command/src/commands/config/clear.rs | 2 +- .../nu-command/src/commands/config/command.rs | 4 +-- crates/nu-command/src/commands/config/get.rs | 4 +-- crates/nu-command/src/commands/config/path.rs | 2 +- .../nu-command/src/commands/config/remove.rs | 4 +-- crates/nu-command/src/commands/config/set.rs | 2 +- .../src/commands/config/set_into.rs | 2 +- crates/nu-command/src/commands/date/format.rs | 2 +- .../src/commands/date/list_timezone.rs | 2 +- .../nu-command/src/commands/date/to_table.rs | 2 +- .../src/commands/date/to_timezone.rs | 2 +- crates/nu-command/src/commands/debug.rs | 2 +- crates/nu-command/src/commands/default.rs | 2 +- crates/nu-command/src/commands/describe.rs | 2 +- crates/nu-command/src/commands/do_.rs | 4 +-- crates/nu-command/src/commands/drop/column.rs | 2 +- .../nu-command/src/commands/drop/command.rs | 4 +-- crates/nu-command/src/commands/du.rs | 2 +- crates/nu-command/src/commands/each/group.rs | 2 +- crates/nu-command/src/commands/each/window.rs | 2 +- crates/nu-command/src/commands/empty.rs | 4 +-- crates/nu-command/src/commands/enter.rs | 2 +- crates/nu-command/src/commands/every.rs | 2 +- crates/nu-command/src/commands/first.rs | 2 +- crates/nu-command/src/commands/flatten.rs | 2 +- .../nu-command/src/commands/format/command.rs | 2 +- .../src/commands/format/format_filesize.rs | 2 +- .../src/commands/from_delimited_data.rs | 2 +- crates/nu-command/src/commands/from_ics.rs | 2 +- crates/nu-command/src/commands/from_ini.rs | 2 +- crates/nu-command/src/commands/from_json.rs | 4 +-- crates/nu-command/src/commands/from_ssv.rs | 2 +- crates/nu-command/src/commands/from_toml.rs | 2 +- crates/nu-command/src/commands/from_vcf.rs | 2 +- crates/nu-command/src/commands/from_xml.rs | 2 +- crates/nu-command/src/commands/from_yaml.rs | 2 +- crates/nu-command/src/commands/get.rs | 4 +-- .../nu-command/src/commands/hash_/base64_.rs | 2 +- crates/nu-command/src/commands/hash_/md5_.rs | 2 +- crates/nu-command/src/commands/headers.rs | 2 +- crates/nu-command/src/commands/help.rs | 2 +- crates/nu-command/src/commands/histogram.rs | 2 +- crates/nu-command/src/commands/history.rs | 2 +- crates/nu-command/src/commands/insert.rs | 2 +- crates/nu-command/src/commands/into/int.rs | 2 +- .../nu-command/src/commands/keep/command.rs | 2 +- crates/nu-command/src/commands/keep/until.rs | 2 +- crates/nu-command/src/commands/keep/while_.rs | 2 +- crates/nu-command/src/commands/last.rs | 2 +- crates/nu-command/src/commands/length.rs | 2 +- crates/nu-command/src/commands/lines.rs | 2 +- crates/nu-command/src/commands/macros.rs | 2 +- crates/nu-command/src/commands/math/eval.rs | 2 +- crates/nu-command/src/commands/merge.rs | 2 +- .../nu-command/src/commands/move_/command.rs | 4 +-- crates/nu-command/src/commands/nth.rs | 2 +- .../nu-command/src/commands/parse/command.rs | 2 +- crates/nu-command/src/commands/path/mod.rs | 2 +- crates/nu-command/src/commands/pivot.rs | 2 +- crates/nu-command/src/commands/prepend.rs | 2 +- crates/nu-command/src/commands/random/dice.rs | 2 +- crates/nu-command/src/commands/range.rs | 2 +- crates/nu-command/src/commands/reduce.rs | 4 +-- crates/nu-command/src/commands/reject.rs | 2 +- crates/nu-command/src/commands/rename.rs | 2 +- crates/nu-command/src/commands/reverse.rs | 2 +- crates/nu-command/src/commands/roll/column.rs | 2 +- .../nu-command/src/commands/roll/command.rs | 2 +- crates/nu-command/src/commands/roll/up.rs | 2 +- .../nu-command/src/commands/rotate/command.rs | 2 +- .../src/commands/rotate/counter_clockwise.rs | 2 +- .../nu-command/src/commands/run_external.rs | 4 +-- crates/nu-command/src/commands/select.rs | 2 +- crates/nu-command/src/commands/seq_dates.rs | 2 +- crates/nu-command/src/commands/shuffle.rs | 2 +- crates/nu-command/src/commands/size.rs | 2 +- .../nu-command/src/commands/skip/command.rs | 2 +- crates/nu-command/src/commands/skip/until.rs | 2 +- crates/nu-command/src/commands/skip/while_.rs | 2 +- crates/nu-command/src/commands/sleep.rs | 2 +- crates/nu-command/src/commands/sort_by.rs | 2 +- crates/nu-command/src/commands/split/chars.rs | 4 +-- .../nu-command/src/commands/split/column.rs | 2 +- crates/nu-command/src/commands/split/row.rs | 4 +-- .../src/commands/str_/capitalize.rs | 2 +- .../nu-command/src/commands/str_/case/mod.rs | 2 +- .../nu-command/src/commands/str_/contains.rs | 2 +- .../nu-command/src/commands/str_/downcase.rs | 2 +- .../nu-command/src/commands/str_/ends_with.rs | 2 +- .../src/commands/str_/find_replace.rs | 2 +- crates/nu-command/src/commands/str_/from.rs | 2 +- .../nu-command/src/commands/str_/index_of.rs | 2 +- crates/nu-command/src/commands/str_/length.rs | 2 +- crates/nu-command/src/commands/str_/lpad.rs | 2 +- .../nu-command/src/commands/str_/reverse.rs | 2 +- crates/nu-command/src/commands/str_/rpad.rs | 2 +- .../src/commands/str_/starts_with.rs | 2 +- .../nu-command/src/commands/str_/substring.rs | 2 +- .../src/commands/str_/to_datetime.rs | 2 +- .../src/commands/str_/to_decimal.rs | 2 +- .../src/commands/str_/to_integer.rs | 2 +- .../nu-command/src/commands/str_/trim/mod.rs | 2 +- crates/nu-command/src/commands/str_/upcase.rs | 2 +- crates/nu-command/src/commands/tags.rs | 2 +- .../src/commands/to_delimited_data.rs | 2 +- crates/nu-command/src/commands/to_json.rs | 2 +- crates/nu-command/src/commands/to_toml.rs | 2 +- crates/nu-command/src/commands/to_url.rs | 2 +- crates/nu-command/src/commands/to_xml.rs | 2 +- crates/nu-command/src/commands/to_yaml.rs | 2 +- crates/nu-command/src/commands/uniq.rs | 2 +- crates/nu-command/src/commands/update.rs | 2 +- crates/nu-command/src/commands/url_/mod.rs | 2 +- crates/nu-command/src/commands/where_.rs | 2 +- crates/nu-command/src/commands/which_.rs | 2 +- crates/nu-command/src/commands/with_env.rs | 2 +- crates/nu-command/src/commands/wrap.rs | 2 +- crates/nu-command/src/examples/double_echo.rs | 8 ++--- crates/nu-command/src/examples/double_ls.rs | 4 +-- crates/nu-command/src/prelude.rs | 6 ++-- crates/nu-engine/src/evaluate/block.rs | 4 +-- .../src/filesystem/filesystem_shell.rs | 6 ++-- crates/nu-engine/src/plugin/run_plugin.rs | 32 ++++++++----------- crates/nu-stream/src/lib.rs | 2 +- crates/nu-stream/src/prelude.rs | 8 ++--- 132 files changed, 169 insertions(+), 192 deletions(-) diff --git a/crates/nu-cli/src/prelude.rs b/crates/nu-cli/src/prelude.rs index b7aea3727302..535908268c3a 100644 --- a/crates/nu-cli/src/prelude.rs +++ b/crates/nu-cli/src/prelude.rs @@ -57,20 +57,3 @@ where } } } - -#[allow(clippy::clippy::wrong_self_convention)] -pub trait ToOutputStream { - fn to_output_stream(self) -> ActionStream; -} - -impl ToOutputStream for T -where - T: Iterator + Send + Sync + 'static, - U: Into, -{ - fn to_output_stream(self) -> ActionStream { - ActionStream { - values: Box::new(self.map(|item| item.into())), - } - } -} diff --git a/crates/nu-command/src/commands/all.rs b/crates/nu-command/src/commands/all.rs index b905887e1855..1a5d284b3972 100644 --- a/crates/nu-command/src/commands/all.rs +++ b/crates/nu-command/src/commands/all.rs @@ -5,7 +5,7 @@ use nu_errors::ShellError; use nu_protocol::{ hir::CapturedBlock, hir::ClassifiedCommand, Signature, SyntaxShape, UntaggedValue, }; -use nu_stream::ToOutputStreamWithActions; +use nu_stream::ToActionStream; pub struct Command; @@ -118,7 +118,7 @@ fn all(args: CommandArgs) -> Result { Err(e) => Err(e), } })? - .to_output_stream_with_actions()) + .to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/ansi/strip.rs b/crates/nu-command/src/commands/ansi/strip.rs index 8235087b7c27..279288800efe 100644 --- a/crates/nu-command/src/commands/ansi/strip.rs +++ b/crates/nu-command/src/commands/ansi/strip.rs @@ -65,7 +65,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } fn action(input: &Value, tag: impl Into) -> Result { diff --git a/crates/nu-command/src/commands/any.rs b/crates/nu-command/src/commands/any.rs index ba902a14c32f..7a40df7bcb6f 100644 --- a/crates/nu-command/src/commands/any.rs +++ b/crates/nu-command/src/commands/any.rs @@ -117,7 +117,7 @@ fn any(args: CommandArgs) -> Result { Err(e) => Err(e), } })? - .to_output_stream_with_actions()) + .to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/append.rs b/crates/nu-command/src/commands/append.rs index 434586e8a7ef..2ed0c7f33da0 100644 --- a/crates/nu-command/src/commands/append.rs +++ b/crates/nu-command/src/commands/append.rs @@ -51,7 +51,7 @@ impl WholeStreamCommand for Command { .into_iter() .chain(vec![value]) .map(ReturnSuccess::value) - .to_output_stream_with_actions()) + .to_action_stream()) } fn examples(&self) -> Vec { diff --git a/crates/nu-command/src/commands/cal.rs b/crates/nu-command/src/commands/cal.rs index 8c181dfe7b50..0bc66ed37c2b 100644 --- a/crates/nu-command/src/commands/cal.rs +++ b/crates/nu-command/src/commands/cal.rs @@ -103,7 +103,7 @@ pub fn cal(args: CommandArgs) -> Result { Ok(calendar_vec_deque .into_iter() - .to_output_stream_with_actions()) + .to_action_stream()) } fn get_invalid_year_shell_error(year_tag: &Tag) -> ShellError { diff --git a/crates/nu-command/src/commands/compact.rs b/crates/nu-command/src/commands/compact.rs index 44dff98c1c9e..5988cdf29f3d 100644 --- a/crates/nu-command/src/commands/compact.rs +++ b/crates/nu-command/src/commands/compact.rs @@ -67,7 +67,7 @@ pub fn compact(args: CommandArgs) -> Result { } } }) - .to_output_stream_with_actions()) + .to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/config/clear.rs b/crates/nu-command/src/commands/config/clear.rs index 53e4d7bb9e5e..3a2b1e44dd4c 100644 --- a/crates/nu-command/src/commands/config/clear.rs +++ b/crates/nu-command/src/commands/config/clear.rs @@ -46,7 +46,7 @@ pub fn clear(args: CommandArgs) -> Result { crate::commands::config::err_no_global_cfg_present(), ))] .into_iter() - .to_output_stream_with_actions()) + .to_action_stream()) }; result diff --git a/crates/nu-command/src/commands/config/command.rs b/crates/nu-command/src/commands/config/command.rs index c8e4e0f3404f..cf9b4fc4bc77 100644 --- a/crates/nu-command/src/commands/config/command.rs +++ b/crates/nu-command/src/commands/config/command.rs @@ -29,13 +29,13 @@ impl WholeStreamCommand for Command { UntaggedValue::Row(result.into()).into_value(name), )] .into_iter() - .to_output_stream_with_actions()) + .to_action_stream()) } else { Ok(vec![ReturnSuccess::value(UntaggedValue::Error( crate::commands::config::err_no_global_cfg_present(), ))] .into_iter() - .to_output_stream_with_actions()) + .to_action_stream()) } } } diff --git a/crates/nu-command/src/commands/config/get.rs b/crates/nu-command/src/commands/config/get.rs index bc3801fedfd2..3d07c81c3e45 100644 --- a/crates/nu-command/src/commands/config/get.rs +++ b/crates/nu-command/src/commands/config/get.rs @@ -53,7 +53,7 @@ pub fn get(args: CommandArgs) -> Result { Value { value: UntaggedValue::Table(list), .. - } => list.into_iter().to_output_stream_with_actions(), + } => list.into_iter().to_action_stream(), x => ActionStream::one(ReturnSuccess::value(x)), }) } else { @@ -61,7 +61,7 @@ pub fn get(args: CommandArgs) -> Result { crate::commands::config::err_no_global_cfg_present(), ))] .into_iter() - .to_output_stream_with_actions()) + .to_action_stream()) }; result diff --git a/crates/nu-command/src/commands/config/path.rs b/crates/nu-command/src/commands/config/path.rs index 5f7a5f725e77..81e6c1aaf544 100644 --- a/crates/nu-command/src/commands/config/path.rs +++ b/crates/nu-command/src/commands/config/path.rs @@ -41,6 +41,6 @@ pub fn path(args: CommandArgs) -> Result { crate::commands::config::err_no_global_cfg_present(), ))] .into_iter() - .to_output_stream_with_actions()) + .to_action_stream()) } } diff --git a/crates/nu-command/src/commands/config/remove.rs b/crates/nu-command/src/commands/config/remove.rs index 7049ed13258f..c8ecb4c1bba3 100644 --- a/crates/nu-command/src/commands/config/remove.rs +++ b/crates/nu-command/src/commands/config/remove.rs @@ -56,7 +56,7 @@ pub fn remove(args: CommandArgs) -> Result { UntaggedValue::row(global_cfg.vars.clone()).into_value(remove.tag()), )] .into_iter() - .to_output_stream_with_actions()) + .to_action_stream()) } else { Err(ShellError::labeled_error( "Key does not exist in config", @@ -69,7 +69,7 @@ pub fn remove(args: CommandArgs) -> Result { crate::commands::config::err_no_global_cfg_present(), ))] .into_iter() - .to_output_stream_with_actions()) + .to_action_stream()) }; result diff --git a/crates/nu-command/src/commands/config/set.rs b/crates/nu-command/src/commands/config/set.rs index 4a88bcac7bb4..cdb4c97f2513 100644 --- a/crates/nu-command/src/commands/config/set.rs +++ b/crates/nu-command/src/commands/config/set.rs @@ -97,7 +97,7 @@ pub fn set(args: CommandArgs) -> Result { crate::commands::config::err_no_global_cfg_present(), ))] .into_iter() - .to_output_stream_with_actions()) + .to_action_stream()) }; result diff --git a/crates/nu-command/src/commands/config/set_into.rs b/crates/nu-command/src/commands/config/set_into.rs index 5b7dec52c55a..f0ac37569162 100644 --- a/crates/nu-command/src/commands/config/set_into.rs +++ b/crates/nu-command/src/commands/config/set_into.rs @@ -79,7 +79,7 @@ pub fn set_into(args: CommandArgs) -> Result { crate::commands::config::err_no_global_cfg_present(), ))] .into_iter() - .to_output_stream_with_actions()) + .to_action_stream()) }; result diff --git a/crates/nu-command/src/commands/date/format.rs b/crates/nu-command/src/commands/date/format.rs index bb9e110e707f..f86bc6d1f722 100644 --- a/crates/nu-command/src/commands/date/format.rs +++ b/crates/nu-command/src/commands/date/format.rs @@ -91,7 +91,7 @@ pub fn format(args: CommandArgs) -> Result { &tag, )), }) - .to_output_stream_with_actions()) + .to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/date/list_timezone.rs b/crates/nu-command/src/commands/date/list_timezone.rs index 4597c8f2bece..6b19588e65ca 100644 --- a/crates/nu-command/src/commands/date/list_timezone.rs +++ b/crates/nu-command/src/commands/date/list_timezone.rs @@ -57,7 +57,7 @@ fn list_timezone(args: CommandArgs) -> Result { )) }); - Ok(list.into_iter().to_output_stream_with_actions()) + Ok(list.into_iter().to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/date/to_table.rs b/crates/nu-command/src/commands/date/to_table.rs index c366734d13e8..aa04eb618c6a 100644 --- a/crates/nu-command/src/commands/date/to_table.rs +++ b/crates/nu-command/src/commands/date/to_table.rs @@ -87,7 +87,7 @@ fn to_table(args: CommandArgs) -> Result { &tag, )), }) - .to_output_stream_with_actions()) + .to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/date/to_timezone.rs b/crates/nu-command/src/commands/date/to_timezone.rs index 24657740248f..d9f7bf4b748e 100644 --- a/crates/nu-command/src/commands/date/to_timezone.rs +++ b/crates/nu-command/src/commands/date/to_timezone.rs @@ -85,7 +85,7 @@ fn to_timezone(args: CommandArgs) -> Result { &tag, )), }) - .to_output_stream_with_actions()) + .to_action_stream()) } fn error_message(err: ParseErrorKind) -> &'static str { diff --git a/crates/nu-command/src/commands/debug.rs b/crates/nu-command/src/commands/debug.rs index cb16977a3db3..b1adf564db48 100644 --- a/crates/nu-command/src/commands/debug.rs +++ b/crates/nu-command/src/commands/debug.rs @@ -40,7 +40,7 @@ fn debug_value(args: CommandArgs) -> Result { ReturnSuccess::debug_value(v) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/default.rs b/crates/nu-command/src/commands/default.rs index b09be73c1d26..5ed7802a77a8 100644 --- a/crates/nu-command/src/commands/default.rs +++ b/crates/nu-command/src/commands/default.rs @@ -67,7 +67,7 @@ fn default(args: CommandArgs) -> Result { ReturnSuccess::value(item) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/describe.rs b/crates/nu-command/src/commands/describe.rs index 33190469a289..a593dadeb44b 100644 --- a/crates/nu-command/src/commands/describe.rs +++ b/crates/nu-command/src/commands/describe.rs @@ -36,7 +36,7 @@ pub fn describe(args: CommandArgs) -> Result { UntaggedValue::string(name).into_value(Tag::unknown_anchor(row.tag.span)), ) }) - .to_output_stream_with_actions()) + .to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/do_.rs b/crates/nu-command/src/commands/do_.rs index 0fb7e1b04a46..fa1d891c0c1e 100644 --- a/crates/nu-command/src/commands/do_.rs +++ b/crates/nu-command/src/commands/do_.rs @@ -96,12 +96,12 @@ fn do_(raw_args: CommandArgs) -> Result { Ok(mut stream) => { let output = stream.drain_vec(); context.clear_errors(); - Ok(output.into_iter().to_output_stream_with_actions()) + Ok(output.into_iter().to_action_stream()) } Err(_) => Ok(ActionStream::empty()), } } else { - result.map(|x| x.to_output_stream_with_actions()) + result.map(|x| x.to_action_stream()) } } diff --git a/crates/nu-command/src/commands/drop/column.rs b/crates/nu-command/src/commands/drop/column.rs index 141c5ec34d03..7d500d494faf 100644 --- a/crates/nu-command/src/commands/drop/column.rs +++ b/crates/nu-command/src/commands/drop/column.rs @@ -69,7 +69,7 @@ fn drop(args: CommandArgs) -> Result { select_fields(&item, descs, item.tag()) }) .map(ReturnSuccess::value) - .to_output_stream_with_actions()) + .to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/drop/command.rs b/crates/nu-command/src/commands/drop/command.rs index c29656d5cabf..230f93ad6a70 100644 --- a/crates/nu-command/src/commands/drop/command.rs +++ b/crates/nu-command/src/commands/drop/command.rs @@ -62,7 +62,7 @@ fn drop(args: CommandArgs) -> Result { }; Ok(if rows_to_drop == 0 { - v.into_iter().to_output_stream_with_actions() + v.into_iter().to_action_stream() } else { let k = if v.len() < rows_to_drop { 0 @@ -72,6 +72,6 @@ fn drop(args: CommandArgs) -> Result { let iter = v.into_iter().take(k); - iter.to_output_stream_with_actions() + iter.to_action_stream() }) } diff --git a/crates/nu-command/src/commands/du.rs b/crates/nu-command/src/commands/du.rs index d3ab40d94c21..0bb541cfa227 100644 --- a/crates/nu-command/src/commands/du.rs +++ b/crates/nu-command/src/commands/du.rs @@ -150,7 +150,7 @@ fn du(args: CommandArgs) -> Result { Err(e) => vec![Err(e)], }) .interruptible(ctrl_c_copy) - .to_output_stream_with_actions()) + .to_action_stream()) } fn glob_err_into(e: GlobError) -> ShellError { diff --git a/crates/nu-command/src/commands/each/group.rs b/crates/nu-command/src/commands/each/group.rs index ee17580d2d54..a9e4fd37483b 100644 --- a/crates/nu-command/src/commands/each/group.rs +++ b/crates/nu-command/src/commands/each/group.rs @@ -56,7 +56,7 @@ impl WholeStreamCommand for EachGroup { Ok(each_group_iterator .flatten() - .to_output_stream_with_actions()) + .to_action_stream()) } } diff --git a/crates/nu-command/src/commands/each/window.rs b/crates/nu-command/src/commands/each/window.rs index 36ea146796bf..e69b57bbd4b9 100644 --- a/crates/nu-command/src/commands/each/window.rs +++ b/crates/nu-command/src/commands/each/window.rs @@ -83,7 +83,7 @@ impl WholeStreamCommand for EachWindow { }) .filter_map(|x| x) .flatten() - .to_output_stream_with_actions()) + .to_action_stream()) } } diff --git a/crates/nu-command/src/commands/empty.rs b/crates/nu-command/src/commands/empty.rs index 93051339d682..cf2f569eb48b 100644 --- a/crates/nu-command/src/commands/empty.rs +++ b/crates/nu-command/src/commands/empty.rs @@ -104,7 +104,7 @@ fn is_empty(args: CommandArgs) -> Result { } }) .flatten() - .to_output_stream_with_actions()); + .to_action_stream()); } Ok(input @@ -120,7 +120,7 @@ fn is_empty(args: CommandArgs) -> Result { } }) .flatten() - .to_output_stream_with_actions()) + .to_action_stream()) } fn process_row( diff --git a/crates/nu-command/src/commands/enter.rs b/crates/nu-command/src/commands/enter.rs index 41dd40c2be8f..ee55f6cdf692 100644 --- a/crates/nu-command/src/commands/enter.rs +++ b/crates/nu-command/src/commands/enter.rs @@ -143,7 +143,7 @@ fn enter(raw_args: CommandArgs) -> Result { ), x => x, }) - .to_output_stream_with_actions()) + .to_action_stream()) } else { Ok(ActionStream::one(ReturnSuccess::action( CommandAction::EnterValueShell(tagged_contents), diff --git a/crates/nu-command/src/commands/every.rs b/crates/nu-command/src/commands/every.rs index 9a0c67122d96..1e86c6067460 100644 --- a/crates/nu-command/src/commands/every.rs +++ b/crates/nu-command/src/commands/every.rs @@ -80,7 +80,7 @@ fn every(args: CommandArgs) -> Result { None } }) - .to_output_stream_with_actions()) + .to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/first.rs b/crates/nu-command/src/commands/first.rs index 83230279a399..98fde6754907 100644 --- a/crates/nu-command/src/commands/first.rs +++ b/crates/nu-command/src/commands/first.rs @@ -59,7 +59,7 @@ fn first(args: CommandArgs) -> Result { 1 }; - Ok(input.take(rows_desired).to_output_stream_with_actions()) + Ok(input.take(rows_desired).to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/flatten.rs b/crates/nu-command/src/commands/flatten.rs index ddfbf9712caf..8c07ff8cf2da 100644 --- a/crates/nu-command/src/commands/flatten.rs +++ b/crates/nu-command/src/commands/flatten.rs @@ -58,7 +58,7 @@ fn flatten(args: CommandArgs) -> Result { Ok(input .map(move |item| flat_value(&columns, &item, &tag).into_iter()) .flatten() - .to_output_stream_with_actions()) + .to_action_stream()) } enum TableInside<'a> { diff --git a/crates/nu-command/src/commands/format/command.rs b/crates/nu-command/src/commands/format/command.rs index fd25e5d46198..2f1dac234a34 100644 --- a/crates/nu-command/src/commands/format/command.rs +++ b/crates/nu-command/src/commands/format/command.rs @@ -84,7 +84,7 @@ fn format_command(args: CommandArgs) -> Result { ReturnSuccess::value(UntaggedValue::string(output).into_untagged_value()) }) - .to_output_stream_with_actions()) + .to_action_stream()) } #[derive(Debug)] diff --git a/crates/nu-command/src/commands/format/format_filesize.rs b/crates/nu-command/src/commands/format/format_filesize.rs index 77d60038bec3..4b5189732ae8 100644 --- a/crates/nu-command/src/commands/format/format_filesize.rs +++ b/crates/nu-command/src/commands/format/format_filesize.rs @@ -106,7 +106,7 @@ fn filesize(raw_args: CommandArgs) -> Result { } }) .flatten() - .to_output_stream_with_actions()) + .to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/from_delimited_data.rs b/crates/nu-command/src/commands/from_delimited_data.rs index a5d59e1b0c5f..d4da77524404 100644 --- a/crates/nu-command/src/commands/from_delimited_data.rs +++ b/crates/nu-command/src/commands/from_delimited_data.rs @@ -61,7 +61,7 @@ pub fn from_delimited_data( Value { value: UntaggedValue::Table(list), .. - } => Ok(list.into_iter().to_output_stream_with_actions()), + } => Ok(list.into_iter().to_action_stream()), x => Ok(ActionStream::one(x)), }, Err(err) => { diff --git a/crates/nu-command/src/commands/from_ics.rs b/crates/nu-command/src/commands/from_ics.rs index 9bd64a810949..a3cd403f2aec 100644 --- a/crates/nu-command/src/commands/from_ics.rs +++ b/crates/nu-command/src/commands/from_ics.rs @@ -52,7 +52,7 @@ fn from_ics(args: CommandArgs) -> Result { } } - Ok(output.into_iter().to_output_stream_with_actions()) + Ok(output.into_iter().to_action_stream()) } fn calendar_to_value(calendar: IcalCalendar, tag: Tag) -> Value { diff --git a/crates/nu-command/src/commands/from_ini.rs b/crates/nu-command/src/commands/from_ini.rs index cfa660bfef8a..9ee741d6e616 100644 --- a/crates/nu-command/src/commands/from_ini.rs +++ b/crates/nu-command/src/commands/from_ini.rs @@ -70,7 +70,7 @@ fn from_ini(args: CommandArgs) -> Result { Value { value: UntaggedValue::Table(list), .. - } => Ok(list.into_iter().to_output_stream_with_actions()), + } => Ok(list.into_iter().to_action_stream()), x => Ok(ActionStream::one(x)), }, Err(_) => Err(ShellError::labeled_error_with_secondary( diff --git a/crates/nu-command/src/commands/from_json.rs b/crates/nu-command/src/commands/from_json.rs index d47323b47cc3..b033d2720bbe 100644 --- a/crates/nu-command/src/commands/from_json.rs +++ b/crates/nu-command/src/commands/from_json.rs @@ -100,7 +100,7 @@ fn from_json(args: CommandArgs) -> Result { } } }) - .to_output_stream_with_actions()) + .to_action_stream()) } else { match from_json_string_to_value(concat_string.item, name_tag.clone()) { Ok(x) => match x { @@ -110,7 +110,7 @@ fn from_json(args: CommandArgs) -> Result { } => Ok(list .into_iter() .map(ReturnSuccess::value) - .to_output_stream_with_actions()), + .to_action_stream()), x => Ok(ActionStream::one(ReturnSuccess::value(x))), }, diff --git a/crates/nu-command/src/commands/from_ssv.rs b/crates/nu-command/src/commands/from_ssv.rs index 8770347310a5..f470ce45c094 100644 --- a/crates/nu-command/src/commands/from_ssv.rs +++ b/crates/nu-command/src/commands/from_ssv.rs @@ -276,7 +276,7 @@ fn from_ssv(args: CommandArgs) -> Result { } => list .into_iter() .map(ReturnSuccess::value) - .to_output_stream_with_actions(), + .to_action_stream(), x => ActionStream::one(ReturnSuccess::value(x)), }, ) diff --git a/crates/nu-command/src/commands/from_toml.rs b/crates/nu-command/src/commands/from_toml.rs index 85692c1f4eda..c7b9f997b201 100644 --- a/crates/nu-command/src/commands/from_toml.rs +++ b/crates/nu-command/src/commands/from_toml.rs @@ -75,7 +75,7 @@ pub fn from_toml(args: CommandArgs) -> Result { } => list .into_iter() .map(ReturnSuccess::value) - .to_output_stream_with_actions(), + .to_action_stream(), x => ActionStream::one(ReturnSuccess::value(x)), }, Err(_) => { diff --git a/crates/nu-command/src/commands/from_vcf.rs b/crates/nu-command/src/commands/from_vcf.rs index 241609fa45a2..5a28045b2259 100644 --- a/crates/nu-command/src/commands/from_vcf.rs +++ b/crates/nu-command/src/commands/from_vcf.rs @@ -47,7 +47,7 @@ fn from_vcf(args: CommandArgs) -> Result { let collected: Vec<_> = iter.collect(); - Ok(collected.into_iter().to_output_stream_with_actions()) + Ok(collected.into_iter().to_action_stream()) } fn contact_to_value(contact: VcardContact, tag: Tag) -> Value { diff --git a/crates/nu-command/src/commands/from_xml.rs b/crates/nu-command/src/commands/from_xml.rs index 85c07204d6f0..b088359edd1e 100644 --- a/crates/nu-command/src/commands/from_xml.rs +++ b/crates/nu-command/src/commands/from_xml.rs @@ -110,7 +110,7 @@ fn from_xml(args: CommandArgs) -> Result { } => list .into_iter() .map(ReturnSuccess::value) - .to_output_stream_with_actions(), + .to_action_stream(), x => ActionStream::one(ReturnSuccess::value(x)), }, Err(_) => { diff --git a/crates/nu-command/src/commands/from_yaml.rs b/crates/nu-command/src/commands/from_yaml.rs index d2cf22859b7c..f06f2bd9e0f3 100644 --- a/crates/nu-command/src/commands/from_yaml.rs +++ b/crates/nu-command/src/commands/from_yaml.rs @@ -143,7 +143,7 @@ fn from_yaml(args: CommandArgs) -> Result { Value { value: UntaggedValue::Table(list), .. - } => Ok(list.into_iter().to_output_stream_with_actions()), + } => Ok(list.into_iter().to_action_stream()), x => Ok(ActionStream::one(x)), }, Err(_) => Err(ShellError::labeled_error_with_secondary( diff --git a/crates/nu-command/src/commands/get.rs b/crates/nu-command/src/commands/get.rs index e97618774c97..6da881f8d5c6 100644 --- a/crates/nu-command/src/commands/get.rs +++ b/crates/nu-command/src/commands/get.rs @@ -66,7 +66,7 @@ pub fn get(args: CommandArgs) -> Result { Ok(descs .into_iter() .map(ReturnSuccess::value) - .to_output_stream_with_actions()) + .to_action_stream()) } else { trace!("get {:?}", column_paths); let output_stream = input @@ -78,7 +78,7 @@ pub fn get(args: CommandArgs) -> Result { .collect::>() }) .flatten() - .to_output_stream_with_actions(); + .to_action_stream(); Ok(output_stream) } } diff --git a/crates/nu-command/src/commands/hash_/base64_.rs b/crates/nu-command/src/commands/hash_/base64_.rs index 18adf189f19b..74e8bf1331ea 100644 --- a/crates/nu-command/src/commands/hash_/base64_.rs +++ b/crates/nu-command/src/commands/hash_/base64_.rs @@ -154,7 +154,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } fn action( diff --git a/crates/nu-command/src/commands/hash_/md5_.rs b/crates/nu-command/src/commands/hash_/md5_.rs index e14da4310084..1f9cfce07a14 100644 --- a/crates/nu-command/src/commands/hash_/md5_.rs +++ b/crates/nu-command/src/commands/hash_/md5_.rs @@ -78,7 +78,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } fn action(input: &Value, tag: impl Into) -> Result { diff --git a/crates/nu-command/src/commands/headers.rs b/crates/nu-command/src/commands/headers.rs index 2b4f070ee262..800d18d24732 100644 --- a/crates/nu-command/src/commands/headers.rs +++ b/crates/nu-command/src/commands/headers.rs @@ -102,7 +102,7 @@ pub fn headers(args: CommandArgs) -> Result { )), } }) - .to_output_stream_with_actions()) + .to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/help.rs b/crates/nu-command/src/commands/help.rs index c1ff0248e35d..c9e07a287ddd 100644 --- a/crates/nu-command/src/commands/help.rs +++ b/crates/nu-command/src/commands/help.rs @@ -154,7 +154,7 @@ fn help(args: CommandArgs) -> Result { ReturnSuccess::value(short_desc.into_value()) }); - Ok(iterator.to_output_stream_with_actions()) + Ok(iterator.to_action_stream()) } else if rest[0].item == "generate_docs" { Ok(ActionStream::one(ReturnSuccess::value(generate_docs( &scope, diff --git a/crates/nu-command/src/commands/histogram.rs b/crates/nu-command/src/commands/histogram.rs index 21e2c56541b5..f81da3a4469c 100644 --- a/crates/nu-command/src/commands/histogram.rs +++ b/crates/nu-command/src/commands/histogram.rs @@ -177,7 +177,7 @@ pub fn histogram(args: CommandArgs) -> Result { ReturnSuccess::value(fact.into_value()) }) - .to_output_stream_with_actions()) + .to_action_stream()) } fn evaluator(by: ColumnPath) -> Box Result + Send> { diff --git a/crates/nu-command/src/commands/history.rs b/crates/nu-command/src/commands/history.rs index 76d6dc646df6..4e9f22fd2908 100644 --- a/crates/nu-command/src/commands/history.rs +++ b/crates/nu-command/src/commands/history.rs @@ -57,7 +57,7 @@ fn history(args: CommandArgs) -> Result { Err(_) => None, }); - Ok(output.to_output_stream_with_actions()) + Ok(output.to_action_stream()) } else { Err(ShellError::labeled_error( "Could not open history", diff --git a/crates/nu-command/src/commands/insert.rs b/crates/nu-command/src/commands/insert.rs index e86bfd4322eb..734c036a17e9 100644 --- a/crates/nu-command/src/commands/insert.rs +++ b/crates/nu-command/src/commands/insert.rs @@ -168,5 +168,5 @@ fn insert(raw_args: CommandArgs) -> Result { } }) .flatten() - .to_output_stream_with_actions()) + .to_action_stream()) } diff --git a/crates/nu-command/src/commands/into/int.rs b/crates/nu-command/src/commands/into/int.rs index c105478954f2..918b07131894 100644 --- a/crates/nu-command/src/commands/into/int.rs +++ b/crates/nu-command/src/commands/into/int.rs @@ -104,7 +104,7 @@ fn into_int(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } pub fn action(input: &Value, tag: impl Into) -> Result { diff --git a/crates/nu-command/src/commands/keep/command.rs b/crates/nu-command/src/commands/keep/command.rs index 52b0e649c453..06b356f94c1b 100644 --- a/crates/nu-command/src/commands/keep/command.rs +++ b/crates/nu-command/src/commands/keep/command.rs @@ -61,7 +61,7 @@ fn keep(args: CommandArgs) -> Result { 1 }; - Ok(input.take(rows_desired).to_output_stream_with_actions()) + Ok(input.take(rows_desired).to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/keep/until.rs b/crates/nu-command/src/commands/keep/until.rs index 304d069e379c..9313e9532cb5 100644 --- a/crates/nu-command/src/commands/keep/until.rs +++ b/crates/nu-command/src/commands/keep/until.rs @@ -93,7 +93,7 @@ impl WholeStreamCommand for SubCommand { !matches!(result, Ok(ref v) if v.is_true()) }) - .to_output_stream_with_actions()) + .to_action_stream()) } } diff --git a/crates/nu-command/src/commands/keep/while_.rs b/crates/nu-command/src/commands/keep/while_.rs index 175281eefe2f..0688e0d55127 100644 --- a/crates/nu-command/src/commands/keep/while_.rs +++ b/crates/nu-command/src/commands/keep/while_.rs @@ -92,7 +92,7 @@ impl WholeStreamCommand for SubCommand { matches!(result, Ok(ref v) if v.is_true()) }) - .to_output_stream_with_actions()) + .to_action_stream()) } } diff --git a/crates/nu-command/src/commands/last.rs b/crates/nu-command/src/commands/last.rs index 628445ffb8f4..a247f31e576b 100644 --- a/crates/nu-command/src/commands/last.rs +++ b/crates/nu-command/src/commands/last.rs @@ -70,7 +70,7 @@ fn last(args: CommandArgs) -> Result { let iter = v.into_iter().skip(beginning_rows_to_skip); - Ok((iter).to_output_stream_with_actions()) + Ok((iter).to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/length.rs b/crates/nu-command/src/commands/length.rs index 571bf897904d..ffb0786896de 100644 --- a/crates/nu-command/src/commands/length.rs +++ b/crates/nu-command/src/commands/length.rs @@ -38,7 +38,7 @@ impl WholeStreamCommand for Length { done: false, tag, } - .to_output_stream_with_actions()) + .to_action_stream()) } fn examples(&self) -> Vec { diff --git a/crates/nu-command/src/commands/lines.rs b/crates/nu-command/src/commands/lines.rs index 5572a22e7bdb..fd5529c528b6 100644 --- a/crates/nu-command/src/commands/lines.rs +++ b/crates/nu-command/src/commands/lines.rs @@ -113,7 +113,7 @@ fn lines(args: CommandArgs) -> Result { } }) .flatten() - .to_output_stream_with_actions()) + .to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/macros.rs b/crates/nu-command/src/commands/macros.rs index 7403b69215e0..844d133df4cf 100644 --- a/crates/nu-command/src/commands/macros.rs +++ b/crates/nu-command/src/commands/macros.rs @@ -33,7 +33,7 @@ macro_rules! command { fn command($args: EvaluatedCommandArgs, ( $($param_name),*, ): ( $($param_type),*, )) -> Result { let output = $body; - Ok(output.to_output_stream_with_actions()) + Ok(output.to_action_stream()) } let $args = $args.evaluate_once(registry)?; diff --git a/crates/nu-command/src/commands/math/eval.rs b/crates/nu-command/src/commands/math/eval.rs index 7dc61f60301a..9077802271d3 100644 --- a/crates/nu-command/src/commands/math/eval.rs +++ b/crates/nu-command/src/commands/math/eval.rs @@ -89,7 +89,7 @@ pub fn eval(args: CommandArgs) -> Result { )) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } } diff --git a/crates/nu-command/src/commands/merge.rs b/crates/nu-command/src/commands/merge.rs index 644d9a35b9ea..0249c8dd2d43 100644 --- a/crates/nu-command/src/commands/merge.rs +++ b/crates/nu-command/src/commands/merge.rs @@ -90,7 +90,7 @@ fn merge(raw_args: CommandArgs) -> Result { None => ReturnSuccess::value(value), } }) - .to_output_stream_with_actions()) + .to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/move_/command.rs b/crates/nu-command/src/commands/move_/command.rs index 24fdfdfdf430..4a74bae41a8e 100644 --- a/crates/nu-command/src/commands/move_/command.rs +++ b/crates/nu-command/src/commands/move_/command.rs @@ -169,7 +169,7 @@ fn operate(raw_args: CommandArgs) -> Result { )) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } else if let Some(before) = before { let member = columns.remove(0); @@ -217,7 +217,7 @@ fn operate(raw_args: CommandArgs) -> Result { )) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } else { Err(ShellError::labeled_error( "no columns given", diff --git a/crates/nu-command/src/commands/nth.rs b/crates/nu-command/src/commands/nth.rs index aa0f99bb29ac..8f7c053e50f5 100644 --- a/crates/nu-command/src/commands/nth.rs +++ b/crates/nu-command/src/commands/nth.rs @@ -83,7 +83,7 @@ fn nth(args: CommandArgs) -> Result { None } }) - .to_output_stream_with_actions()) + .to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/parse/command.rs b/crates/nu-command/src/commands/parse/command.rs index 40bca4af83bc..483b78fbed1a 100644 --- a/crates/nu-command/src/commands/parse/command.rs +++ b/crates/nu-command/src/commands/parse/command.rs @@ -95,7 +95,7 @@ pub fn operate(args: CommandArgs) -> Result { } } - Ok(parsed.into_iter().to_output_stream_with_actions()) + Ok(parsed.into_iter().to_action_stream()) } fn build_regex(input: &str, tag: Tag) -> Result { diff --git a/crates/nu-command/src/commands/path/mod.rs b/crates/nu-command/src/commands/path/mod.rs index 4daeeebba7c2..d42baa1394fa 100644 --- a/crates/nu-command/src/commands/path/mod.rs +++ b/crates/nu-command/src/commands/path/mod.rs @@ -83,5 +83,5 @@ where ReturnSuccess::value(ret) } }) - .to_output_stream_with_actions() + .to_action_stream() } diff --git a/crates/nu-command/src/commands/pivot.rs b/crates/nu-command/src/commands/pivot.rs index 4939e29e9521..23c493de6706 100644 --- a/crates/nu-command/src/commands/pivot.rs +++ b/crates/nu-command/src/commands/pivot.rs @@ -140,7 +140,7 @@ pub fn pivot(args: CommandArgs) -> Result { ReturnSuccess::value(dict.into_value()) })) - .to_output_stream_with_actions()) + .to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/prepend.rs b/crates/nu-command/src/commands/prepend.rs index f375cb8dcc02..9e06b28aeb1c 100644 --- a/crates/nu-command/src/commands/prepend.rs +++ b/crates/nu-command/src/commands/prepend.rs @@ -50,7 +50,7 @@ fn prepend(args: CommandArgs) -> Result { let bos = vec![row].into_iter(); - Ok(bos.chain(input).to_output_stream_with_actions()) + Ok(bos.chain(input).to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/random/dice.rs b/crates/nu-command/src/commands/random/dice.rs index d93d5e833bd1..9f4b18a81a06 100644 --- a/crates/nu-command/src/commands/random/dice.rs +++ b/crates/nu-command/src/commands/random/dice.rs @@ -79,7 +79,7 @@ pub fn dice(args: CommandArgs) -> Result { UntaggedValue::int(thread_rng.gen_range(1, sides + 1)).into_value(tag.clone()) }); - Ok((iter).to_output_stream_with_actions()) + Ok((iter).to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/range.rs b/crates/nu-command/src/commands/range.rs index 4bcf5e3e3bd4..364fb0a15cdc 100644 --- a/crates/nu-command/src/commands/range.rs +++ b/crates/nu-command/src/commands/range.rs @@ -59,7 +59,7 @@ fn range(args: CommandArgs) -> Result { .skip(from) .take(to - from + 1) .map(ReturnSuccess::value) - .to_output_stream_with_actions()) + .to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/reduce.rs b/crates/nu-command/src/commands/reduce.rs index 660aa28af205..b0d2eb0aa951 100644 --- a/crates/nu-command/src/commands/reduce.rs +++ b/crates/nu-command/src/commands/reduce.rs @@ -150,7 +150,7 @@ fn reduce(raw_args: CommandArgs) -> Result { result })? - .to_output_stream_with_actions()) + .to_action_stream()) } else { let initial = Ok(InputStream::one(start)); Ok(input @@ -177,7 +177,7 @@ fn reduce(raw_args: CommandArgs) -> Result { context.scope.exit_scope(); result })? - .to_output_stream_with_actions()) + .to_action_stream()) } } diff --git a/crates/nu-command/src/commands/reject.rs b/crates/nu-command/src/commands/reject.rs index 5ca4abb41ad7..1926aaf058a8 100644 --- a/crates/nu-command/src/commands/reject.rs +++ b/crates/nu-command/src/commands/reject.rs @@ -53,7 +53,7 @@ fn reject(args: CommandArgs) -> Result { Ok(input .map(move |item| ReturnSuccess::value(reject_fields(&item, &fields, &item.tag))) - .to_output_stream_with_actions()) + .to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/rename.rs b/crates/nu-command/src/commands/rename.rs index 05f63fb9a965..96342ecc9f60 100644 --- a/crates/nu-command/src/commands/rename.rs +++ b/crates/nu-command/src/commands/rename.rs @@ -102,7 +102,7 @@ pub fn rename(args: CommandArgs) -> Result { ) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/reverse.rs b/crates/nu-command/src/commands/reverse.rs index 51e91b85536f..8c3391eb02bc 100644 --- a/crates/nu-command/src/commands/reverse.rs +++ b/crates/nu-command/src/commands/reverse.rs @@ -42,7 +42,7 @@ fn reverse(args: CommandArgs) -> Result { let (input, _args) = args.parts(); let input = input.collect::>(); - Ok((input.into_iter().rev().map(ReturnSuccess::value)).to_output_stream_with_actions()) + Ok((input.into_iter().rev().map(ReturnSuccess::value)).to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/roll/column.rs b/crates/nu-command/src/commands/roll/column.rs index bf9cd8ab90b5..180fc6954465 100644 --- a/crates/nu-command/src/commands/roll/column.rs +++ b/crates/nu-command/src/commands/roll/column.rs @@ -65,7 +65,7 @@ pub fn roll(args: CommandArgs) -> Result { .map(ReturnSuccess::value) }) .flatten() - .to_output_stream_with_actions()) + .to_action_stream()) } fn roll_by(value: Value, options: &Arguments) -> Option> { diff --git a/crates/nu-command/src/commands/roll/command.rs b/crates/nu-command/src/commands/roll/command.rs index de07aec83590..3d8bf2831449 100644 --- a/crates/nu-command/src/commands/roll/command.rs +++ b/crates/nu-command/src/commands/roll/command.rs @@ -41,7 +41,7 @@ pub fn roll(args: CommandArgs) -> Result { .unwrap_or_else(|| vec![UntaggedValue::nothing().into_value(&name)]) .into_iter() .map(ReturnSuccess::value)) - .to_output_stream_with_actions()) + .to_action_stream()) } fn roll_down(values: Vec, Arguments { by: ref n }: &Arguments) -> Option> { diff --git a/crates/nu-command/src/commands/roll/up.rs b/crates/nu-command/src/commands/roll/up.rs index 194a549aa0b6..d4ca29d8d1a7 100644 --- a/crates/nu-command/src/commands/roll/up.rs +++ b/crates/nu-command/src/commands/roll/up.rs @@ -41,7 +41,7 @@ pub fn roll(args: CommandArgs) -> Result { .unwrap_or_else(|| vec![UntaggedValue::nothing().into_value(&name)]) .into_iter() .map(ReturnSuccess::value)) - .to_output_stream_with_actions()) + .to_action_stream()) } fn roll_up(values: Vec, Arguments { by: ref n }: &Arguments) -> Option> { diff --git a/crates/nu-command/src/commands/rotate/command.rs b/crates/nu-command/src/commands/rotate/command.rs index 8bf2ff1c8a54..3dcd37305786 100644 --- a/crates/nu-command/src/commands/rotate/command.rs +++ b/crates/nu-command/src/commands/rotate/command.rs @@ -113,5 +113,5 @@ pub fn rotate(args: CommandArgs) -> Result { .rev() .collect::>()) .into_iter() - .to_output_stream_with_actions()) + .to_action_stream()) } diff --git a/crates/nu-command/src/commands/rotate/counter_clockwise.rs b/crates/nu-command/src/commands/rotate/counter_clockwise.rs index f2d12d699cb9..f8ffd023efcc 100644 --- a/crates/nu-command/src/commands/rotate/counter_clockwise.rs +++ b/crates/nu-command/src/commands/rotate/counter_clockwise.rs @@ -109,5 +109,5 @@ pub fn rotate(args: CommandArgs) -> Result { }) .collect::>()) .into_iter() - .to_output_stream_with_actions()) + .to_action_stream()) } diff --git a/crates/nu-command/src/commands/run_external.rs b/crates/nu-command/src/commands/run_external.rs index 3eac861d98fe..094b770b459b 100644 --- a/crates/nu-command/src/commands/run_external.rs +++ b/crates/nu-command/src/commands/run_external.rs @@ -116,7 +116,7 @@ impl WholeStreamCommand for RunExternalCommand { .shell_manager .cd(cd_args, args.call_info.name_tag.clone()); - return Ok(result?.to_output_stream_with_actions()); + return Ok(result?.to_action_stream()); } } @@ -128,7 +128,7 @@ impl WholeStreamCommand for RunExternalCommand { external_redirection, ); - Ok(result?.to_output_stream_with_actions()) + Ok(result?.to_action_stream()) } } diff --git a/crates/nu-command/src/commands/select.rs b/crates/nu-command/src/commands/select.rs index d9afbe0b3da5..e2f4e1124661 100644 --- a/crates/nu-command/src/commands/select.rs +++ b/crates/nu-command/src/commands/select.rs @@ -155,5 +155,5 @@ fn select(args: CommandArgs) -> Result { ReturnSuccess::value(out.into_value()) })) - .to_output_stream_with_actions()) + .to_action_stream()) } diff --git a/crates/nu-command/src/commands/seq_dates.rs b/crates/nu-command/src/commands/seq_dates.rs index 70a4e38f0411..9cf1f53b2573 100644 --- a/crates/nu-command/src/commands/seq_dates.rs +++ b/crates/nu-command/src/commands/seq_dates.rs @@ -353,7 +353,7 @@ pub fn run_seq_dates( .lines() .map(|v| v.to_str_value_create_tag()) .collect(); - Ok((rows.into_iter().map(ReturnSuccess::value)).to_output_stream_with_actions()) + Ok((rows.into_iter().map(ReturnSuccess::value)).to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/shuffle.rs b/crates/nu-command/src/commands/shuffle.rs index edf625bbebbc..957a3c35a5ce 100644 --- a/crates/nu-command/src/commands/shuffle.rs +++ b/crates/nu-command/src/commands/shuffle.rs @@ -31,7 +31,7 @@ fn shuffle(args: CommandArgs) -> ActionStream { values .into_iter() .map(ReturnSuccess::value) - .to_output_stream_with_actions() + .to_action_stream() } #[cfg(test)] diff --git a/crates/nu-command/src/commands/size.rs b/crates/nu-command/src/commands/size.rs index 3cd7ed9c63a1..f5c1a1932b14 100644 --- a/crates/nu-command/src/commands/size.rs +++ b/crates/nu-command/src/commands/size.rs @@ -73,7 +73,7 @@ fn size(args: CommandArgs) -> ActionStream { )) } }) - .to_output_stream_with_actions() + .to_action_stream() } fn count(contents: &str, tag: impl Into) -> Value { diff --git a/crates/nu-command/src/commands/skip/command.rs b/crates/nu-command/src/commands/skip/command.rs index 0ec4f0445398..957b1d8e44ef 100644 --- a/crates/nu-command/src/commands/skip/command.rs +++ b/crates/nu-command/src/commands/skip/command.rs @@ -48,7 +48,7 @@ fn skip(args: CommandArgs) -> Result { 1 }; - Ok(input.skip(rows_desired).to_output_stream_with_actions()) + Ok(input.skip(rows_desired).to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/skip/until.rs b/crates/nu-command/src/commands/skip/until.rs index e040c8b7bad2..b6a4d8e5bf13 100644 --- a/crates/nu-command/src/commands/skip/until.rs +++ b/crates/nu-command/src/commands/skip/until.rs @@ -92,7 +92,7 @@ impl WholeStreamCommand for SubCommand { !matches!(result, Ok(ref v) if v.is_true()) }) - .to_output_stream_with_actions()) + .to_action_stream()) } } diff --git a/crates/nu-command/src/commands/skip/while_.rs b/crates/nu-command/src/commands/skip/while_.rs index 254f06af74dc..d53d0e00779f 100644 --- a/crates/nu-command/src/commands/skip/while_.rs +++ b/crates/nu-command/src/commands/skip/while_.rs @@ -93,7 +93,7 @@ impl WholeStreamCommand for SubCommand { matches!(result, Ok(ref v) if v.is_true()) }) - .to_output_stream_with_actions()) + .to_action_stream()) } } diff --git a/crates/nu-command/src/commands/sleep.rs b/crates/nu-command/src/commands/sleep.rs index 2a4a5d56ec72..10b44658b7e7 100644 --- a/crates/nu-command/src/commands/sleep.rs +++ b/crates/nu-command/src/commands/sleep.rs @@ -50,7 +50,7 @@ impl WholeStreamCommand for Sleep { // `echo | sleep 1sec` - nothing // `sleep 1sec` - table with 0 elements - Ok(SleepIterator::new(total_dur, ctrl_c).to_output_stream_with_actions()) + Ok(SleepIterator::new(total_dur, ctrl_c).to_action_stream()) // if input.is_empty() { // Ok(OutputStream::empty()) diff --git a/crates/nu-command/src/commands/sort_by.rs b/crates/nu-command/src/commands/sort_by.rs index 91685be5a707..2bb8fd7e0a9c 100644 --- a/crates/nu-command/src/commands/sort_by.rs +++ b/crates/nu-command/src/commands/sort_by.rs @@ -130,7 +130,7 @@ fn sort_by(args: CommandArgs) -> Result { vec.reverse() } - Ok((vec.into_iter()).to_output_stream_with_actions()) + Ok((vec.into_iter()).to_action_stream()) } pub fn sort( diff --git a/crates/nu-command/src/commands/split/chars.rs b/crates/nu-command/src/commands/split/chars.rs index f361baf4e565..185c0acb3ab2 100644 --- a/crates/nu-command/src/commands/split/chars.rs +++ b/crates/nu-command/src/commands/split/chars.rs @@ -47,7 +47,7 @@ fn split_chars(args: CommandArgs) -> ActionStream { .collect::>() .into_iter() .map(move |x| ReturnSuccess::value(Value::from(x.to_string()))) - .to_output_stream_with_actions() + .to_action_stream() } else { ActionStream::one(Err(ShellError::labeled_error_with_secondary( "Expected a string from pipeline", @@ -58,7 +58,7 @@ fn split_chars(args: CommandArgs) -> ActionStream { ))) } }) - .to_output_stream_with_actions() + .to_action_stream() } #[cfg(test)] diff --git a/crates/nu-command/src/commands/split/column.rs b/crates/nu-command/src/commands/split/column.rs index e4fbfb9a074a..745a196d7d67 100644 --- a/crates/nu-command/src/commands/split/column.rs +++ b/crates/nu-command/src/commands/split/column.rs @@ -102,7 +102,7 @@ fn split_column(args: CommandArgs) -> Result { )) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/split/row.rs b/crates/nu-command/src/commands/split/row.rs index 943a8da3ff18..9054d28621ca 100644 --- a/crates/nu-command/src/commands/split/row.rs +++ b/crates/nu-command/src/commands/split/row.rs @@ -60,7 +60,7 @@ fn split_row(args: CommandArgs) -> Result { UntaggedValue::Primitive(Primitive::String(s)).into_value(&v.tag), ) })) - .to_output_stream_with_actions() + .to_action_stream() } else { ActionStream::one(Err(ShellError::labeled_error_with_secondary( "Expected a string from pipeline", @@ -71,7 +71,7 @@ fn split_row(args: CommandArgs) -> Result { ))) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/str_/capitalize.rs b/crates/nu-command/src/commands/str_/capitalize.rs index 707464369a2e..53ad3469f99f 100644 --- a/crates/nu-command/src/commands/str_/capitalize.rs +++ b/crates/nu-command/src/commands/str_/capitalize.rs @@ -67,7 +67,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } fn action(input: &Value, tag: impl Into) -> Result { diff --git a/crates/nu-command/src/commands/str_/case/mod.rs b/crates/nu-command/src/commands/str_/case/mod.rs index 103c9cdc6ebe..9c443b21d6e8 100644 --- a/crates/nu-command/src/commands/str_/case/mod.rs +++ b/crates/nu-command/src/commands/str_/case/mod.rs @@ -47,7 +47,7 @@ where ReturnSuccess::value(ret) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } pub fn action( diff --git a/crates/nu-command/src/commands/str_/contains.rs b/crates/nu-command/src/commands/str_/contains.rs index 8b6dd4944834..1ca803c8b0ec 100644 --- a/crates/nu-command/src/commands/str_/contains.rs +++ b/crates/nu-command/src/commands/str_/contains.rs @@ -83,7 +83,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } fn action( diff --git a/crates/nu-command/src/commands/str_/downcase.rs b/crates/nu-command/src/commands/str_/downcase.rs index d14aa63dea68..bc46984ebe67 100644 --- a/crates/nu-command/src/commands/str_/downcase.rs +++ b/crates/nu-command/src/commands/str_/downcase.rs @@ -67,7 +67,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } fn action(input: &Value, tag: impl Into) -> Result { diff --git a/crates/nu-command/src/commands/str_/ends_with.rs b/crates/nu-command/src/commands/str_/ends_with.rs index 1f373c9eb606..b944e7ffe26d 100644 --- a/crates/nu-command/src/commands/str_/ends_with.rs +++ b/crates/nu-command/src/commands/str_/ends_with.rs @@ -73,7 +73,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } fn action(input: &Value, pattern: &str, tag: impl Into) -> Result { diff --git a/crates/nu-command/src/commands/str_/find_replace.rs b/crates/nu-command/src/commands/str_/find_replace.rs index 70360b2a5a83..90b969ce06e6 100644 --- a/crates/nu-command/src/commands/str_/find_replace.rs +++ b/crates/nu-command/src/commands/str_/find_replace.rs @@ -89,7 +89,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } fn action( diff --git a/crates/nu-command/src/commands/str_/from.rs b/crates/nu-command/src/commands/str_/from.rs index 41b0c7787e76..84fa4488503c 100644 --- a/crates/nu-command/src/commands/str_/from.rs +++ b/crates/nu-command/src/commands/str_/from.rs @@ -100,7 +100,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } // TODO If you're using the with-system-locale feature and you're on Windows, Clang 3.9 or higher is also required. diff --git a/crates/nu-command/src/commands/str_/index_of.rs b/crates/nu-command/src/commands/str_/index_of.rs index 9bee50a523d2..f0b8f1fd79b6 100644 --- a/crates/nu-command/src/commands/str_/index_of.rs +++ b/crates/nu-command/src/commands/str_/index_of.rs @@ -122,7 +122,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } fn action( diff --git a/crates/nu-command/src/commands/str_/length.rs b/crates/nu-command/src/commands/str_/length.rs index 501d83259de4..d19fba3c14dc 100644 --- a/crates/nu-command/src/commands/str_/length.rs +++ b/crates/nu-command/src/commands/str_/length.rs @@ -75,7 +75,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } fn action(input: &Value, tag: impl Into) -> Result { diff --git a/crates/nu-command/src/commands/str_/lpad.rs b/crates/nu-command/src/commands/str_/lpad.rs index a23bfdc94e10..c79d744ba2e6 100644 --- a/crates/nu-command/src/commands/str_/lpad.rs +++ b/crates/nu-command/src/commands/str_/lpad.rs @@ -104,7 +104,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } fn action( diff --git a/crates/nu-command/src/commands/str_/reverse.rs b/crates/nu-command/src/commands/str_/reverse.rs index d22fc3a2de34..9fe8a85121d2 100644 --- a/crates/nu-command/src/commands/str_/reverse.rs +++ b/crates/nu-command/src/commands/str_/reverse.rs @@ -65,7 +65,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } fn action(input: &Value, tag: impl Into) -> Result { diff --git a/crates/nu-command/src/commands/str_/rpad.rs b/crates/nu-command/src/commands/str_/rpad.rs index 4cdfad858fcf..af0cca9a0033 100644 --- a/crates/nu-command/src/commands/str_/rpad.rs +++ b/crates/nu-command/src/commands/str_/rpad.rs @@ -104,7 +104,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } fn action( diff --git a/crates/nu-command/src/commands/str_/starts_with.rs b/crates/nu-command/src/commands/str_/starts_with.rs index 6bae40d64627..8a28afc675e8 100644 --- a/crates/nu-command/src/commands/str_/starts_with.rs +++ b/crates/nu-command/src/commands/str_/starts_with.rs @@ -73,7 +73,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } fn action(input: &Value, pattern: &str, tag: impl Into) -> Result { diff --git a/crates/nu-command/src/commands/str_/substring.rs b/crates/nu-command/src/commands/str_/substring.rs index f4f0ea203088..071eaa16ff69 100644 --- a/crates/nu-command/src/commands/str_/substring.rs +++ b/crates/nu-command/src/commands/str_/substring.rs @@ -117,7 +117,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } fn action(input: &Value, options: &Substring, tag: impl Into) -> Result { diff --git a/crates/nu-command/src/commands/str_/to_datetime.rs b/crates/nu-command/src/commands/str_/to_datetime.rs index 0ec5278d0ded..3f089ca0af99 100644 --- a/crates/nu-command/src/commands/str_/to_datetime.rs +++ b/crates/nu-command/src/commands/str_/to_datetime.rs @@ -195,7 +195,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } fn action( diff --git a/crates/nu-command/src/commands/str_/to_decimal.rs b/crates/nu-command/src/commands/str_/to_decimal.rs index 6751e3a179df..37a1c398f85d 100644 --- a/crates/nu-command/src/commands/str_/to_decimal.rs +++ b/crates/nu-command/src/commands/str_/to_decimal.rs @@ -70,7 +70,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } fn action(input: &Value, tag: impl Into) -> Result { diff --git a/crates/nu-command/src/commands/str_/to_integer.rs b/crates/nu-command/src/commands/str_/to_integer.rs index a7881eb71f90..ccdb36eb03c9 100644 --- a/crates/nu-command/src/commands/str_/to_integer.rs +++ b/crates/nu-command/src/commands/str_/to_integer.rs @@ -100,7 +100,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } fn action(input: &Value, tag: impl Into, radix: u32) -> Result { diff --git a/crates/nu-command/src/commands/str_/trim/mod.rs b/crates/nu-command/src/commands/str_/trim/mod.rs index 699bad4db043..55680593a65e 100644 --- a/crates/nu-command/src/commands/str_/trim/mod.rs +++ b/crates/nu-command/src/commands/str_/trim/mod.rs @@ -61,7 +61,7 @@ where ReturnSuccess::value(ret) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } #[derive(Debug, Copy, Clone)] diff --git a/crates/nu-command/src/commands/str_/upcase.rs b/crates/nu-command/src/commands/str_/upcase.rs index 703fcc93ac40..9d11db4273ff 100644 --- a/crates/nu-command/src/commands/str_/upcase.rs +++ b/crates/nu-command/src/commands/str_/upcase.rs @@ -67,7 +67,7 @@ fn operate(args: CommandArgs) -> Result { ReturnSuccess::value(ret) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } fn action(input: &Value, tag: impl Into) -> Result { diff --git a/crates/nu-command/src/commands/tags.rs b/crates/nu-command/src/commands/tags.rs index 48013aed8ba2..5246b8978d66 100644 --- a/crates/nu-command/src/commands/tags.rs +++ b/crates/nu-command/src/commands/tags.rs @@ -48,7 +48,7 @@ fn tags(args: CommandArgs) -> ActionStream { tags.into_value() }) - .to_output_stream_with_actions() + .to_action_stream() } #[cfg(test)] diff --git a/crates/nu-command/src/commands/to_delimited_data.rs b/crates/nu-command/src/commands/to_delimited_data.rs index 3d920cde4529..cc00c695e940 100644 --- a/crates/nu-command/src/commands/to_delimited_data.rs +++ b/crates/nu-command/src/commands/to_delimited_data.rs @@ -217,5 +217,5 @@ pub fn to_delimited_data( } } })) - .to_output_stream_with_actions()) + .to_action_stream()) } diff --git a/crates/nu-command/src/commands/to_json.rs b/crates/nu-command/src/commands/to_json.rs index 196e71ebce42..d1c4a82a2178 100644 --- a/crates/nu-command/src/commands/to_json.rs +++ b/crates/nu-command/src/commands/to_json.rs @@ -249,7 +249,7 @@ fn to_json(args: CommandArgs) -> Result { &name_tag, )), })) - .to_output_stream_with_actions()) + .to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/to_toml.rs b/crates/nu-command/src/commands/to_toml.rs index 4aed6417e78d..e1ea25b9ce4a 100644 --- a/crates/nu-command/src/commands/to_toml.rs +++ b/crates/nu-command/src/commands/to_toml.rs @@ -179,7 +179,7 @@ fn to_toml(args: CommandArgs) -> Result { )), } })) - .to_output_stream_with_actions()) + .to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/to_url.rs b/crates/nu-command/src/commands/to_url.rs index 25141ce757aa..22cc3a7b37c6 100644 --- a/crates/nu-command/src/commands/to_url.rs +++ b/crates/nu-command/src/commands/to_url.rs @@ -69,7 +69,7 @@ fn to_url(args: CommandArgs) -> Result { value_tag.span, )), }) - .to_output_stream_with_actions()) + .to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/to_xml.rs b/crates/nu-command/src/commands/to_xml.rs index ad85ea00dbc4..340d5263ab80 100644 --- a/crates/nu-command/src/commands/to_xml.rs +++ b/crates/nu-command/src/commands/to_xml.rs @@ -180,7 +180,7 @@ fn to_xml(args: CommandArgs) -> Result { )), } })) - .to_output_stream_with_actions()) + .to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/to_yaml.rs b/crates/nu-command/src/commands/to_yaml.rs index e5c8deb381b8..a4ebbb23f370 100644 --- a/crates/nu-command/src/commands/to_yaml.rs +++ b/crates/nu-command/src/commands/to_yaml.rs @@ -155,7 +155,7 @@ fn to_yaml(args: CommandArgs) -> Result { )), } })) - .to_output_stream_with_actions()) + .to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/uniq.rs b/crates/nu-command/src/commands/uniq.rs index 02bd388bad6b..f8dda95446b9 100644 --- a/crates/nu-command/src/commands/uniq.rs +++ b/crates/nu-command/src/commands/uniq.rs @@ -115,7 +115,7 @@ fn uniq(args: CommandArgs) -> Result { } } - Ok(values_vec_deque.into_iter().to_output_stream_with_actions()) + Ok(values_vec_deque.into_iter().to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/update.rs b/crates/nu-command/src/commands/update.rs index 71b81cbc452b..b9fa95f5fbda 100644 --- a/crates/nu-command/src/commands/update.rs +++ b/crates/nu-command/src/commands/update.rs @@ -189,5 +189,5 @@ fn update(raw_args: CommandArgs) -> Result { } }) .flatten() - .to_output_stream_with_actions()) + .to_action_stream()) } diff --git a/crates/nu-command/src/commands/url_/mod.rs b/crates/nu-command/src/commands/url_/mod.rs index 9e14370b8536..de6cc8479684 100644 --- a/crates/nu-command/src/commands/url_/mod.rs +++ b/crates/nu-command/src/commands/url_/mod.rs @@ -63,5 +63,5 @@ where ReturnSuccess::value(ret) } }) - .to_output_stream_with_actions() + .to_action_stream() } diff --git a/crates/nu-command/src/commands/where_.rs b/crates/nu-command/src/commands/where_.rs index 69eb0f7ae67e..ac2fbc70978b 100644 --- a/crates/nu-command/src/commands/where_.rs +++ b/crates/nu-command/src/commands/where_.rs @@ -119,7 +119,7 @@ fn where_command(raw_args: CommandArgs) -> Result { Err(e) => Some(Err(e)), } }) - .to_output_stream_with_actions()) + .to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/which_.rs b/crates/nu-command/src/commands/which_.rs index 33af7d6d5ef2..7889e55f900d 100644 --- a/crates/nu-command/src/commands/which_.rs +++ b/crates/nu-command/src/commands/which_.rs @@ -233,7 +233,7 @@ fn which(args: CommandArgs) -> Result { output.extend(values); } - Ok((output.into_iter().map(ReturnSuccess::value)).to_output_stream_with_actions()) + Ok((output.into_iter().map(ReturnSuccess::value)).to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/with_env.rs b/crates/nu-command/src/commands/with_env.rs index e02ab29d4d07..a5f883602ce0 100644 --- a/crates/nu-command/src/commands/with_env.rs +++ b/crates/nu-command/src/commands/with_env.rs @@ -121,7 +121,7 @@ fn with_env(raw_args: CommandArgs) -> Result { let result = run_block(&block.block, &context, input); context.scope.exit_scope(); - result.map(|x| x.to_output_stream_with_actions()) + result.map(|x| x.to_action_stream()) } #[cfg(test)] diff --git a/crates/nu-command/src/commands/wrap.rs b/crates/nu-command/src/commands/wrap.rs index 08d779b2c490..57b3f6ff247a 100644 --- a/crates/nu-command/src/commands/wrap.rs +++ b/crates/nu-command/src/commands/wrap.rs @@ -121,7 +121,7 @@ fn wrap(args: CommandArgs) -> Result { Ok(ActionStream::one(ReturnSuccess::value(row))) } else { - Ok((result_table.into_iter().map(ReturnSuccess::value)).to_output_stream_with_actions()) + Ok((result_table.into_iter().map(ReturnSuccess::value)).to_action_stream()) } } diff --git a/crates/nu-command/src/examples/double_echo.rs b/crates/nu-command/src/examples/double_echo.rs index 32829b354113..65524132137f 100644 --- a/crates/nu-command/src/examples/double_echo.rs +++ b/crates/nu-command/src/examples/double_echo.rs @@ -2,7 +2,7 @@ use nu_errors::ShellError; use nu_engine::{CommandArgs, WholeStreamCommand}; use nu_protocol::{Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value}; -use nu_stream::{ActionStream, ToOutputStreamWithActions}; +use nu_stream::{ActionStream, ToActionStream}; use serde::Deserialize; @@ -61,7 +61,7 @@ impl WholeStreamCommand for Command { vec![UntaggedValue::Table(values).into_value(base_value.tag())]; (subtable.into_iter().map(ReturnSuccess::value)) - .to_output_stream_with_actions() + .to_action_stream() } else { (table .into_iter() @@ -70,7 +70,7 @@ impl WholeStreamCommand for Command { v }) .map(ReturnSuccess::value)) - .to_output_stream_with_actions() + .to_action_stream() } } _ => ActionStream::one(Ok(ReturnSuccess::Value(Value { @@ -81,6 +81,6 @@ impl WholeStreamCommand for Command { } }); - Ok((stream).flatten().to_output_stream_with_actions()) + Ok((stream).flatten().to_action_stream()) } } diff --git a/crates/nu-command/src/examples/double_ls.rs b/crates/nu-command/src/examples/double_ls.rs index 475bf2002838..7461a677d66a 100644 --- a/crates/nu-command/src/examples/double_ls.rs +++ b/crates/nu-command/src/examples/double_ls.rs @@ -3,7 +3,7 @@ use crate::examples::sample::ls::file_listing; use nu_engine::{CommandArgs, WholeStreamCommand}; use nu_errors::ShellError; use nu_protocol::{ReturnSuccess, Signature, UntaggedValue, Value}; -use nu_stream::{ActionStream, ToOutputStreamWithActions}; +use nu_stream::{ActionStream, ToActionStream}; pub struct Command; @@ -40,6 +40,6 @@ impl WholeStreamCommand for Command { .collect::>() .into_iter() .map(ReturnSuccess::value)) - .to_output_stream_with_actions()) + .to_action_stream()) } } diff --git a/crates/nu-command/src/prelude.rs b/crates/nu-command/src/prelude.rs index 83f226a51d4a..7bad251fb361 100644 --- a/crates/nu-command/src/prelude.rs +++ b/crates/nu-command/src/prelude.rs @@ -23,7 +23,7 @@ pub(crate) use nu_parser::ParserScope; pub(crate) use nu_protocol::{out, row}; pub(crate) use nu_source::{AnchorLocation, PrettyDebug, Span, SpannedItem, Tag, TaggedItem}; pub(crate) use nu_stream::{ActionStream, InputStream, Interruptible, OutputStream}; -pub(crate) use nu_stream::{ToInputStream, ToOutputStream, ToOutputStreamWithActions}; +pub(crate) use nu_stream::{ToInputStream, ToOutputStream, ToActionStream}; pub(crate) use nu_value_ext::ValueExt; pub(crate) use num_bigint::BigInt; pub(crate) use num_traits::cast::ToPrimitive; @@ -65,7 +65,7 @@ where // #[allow(clippy::wrong_self_convention)] // pub trait ToOutputStreamWithAction { -// fn to_output_stream_with_actions(self) -> ActionStream; +// fn to_action_stream(self) -> ActionStream; // } // impl ToOutputStreamWithAction for T @@ -73,7 +73,7 @@ where // T: Iterator + Send + Sync + 'static, // U: Into, // { -// fn to_output_stream_with_actions(self) -> ActionStream { +// fn to_action_stream(self) -> ActionStream { // ActionStream { // values: Box::new(self.map(|item| item.into())), // } diff --git a/crates/nu-engine/src/evaluate/block.rs b/crates/nu-engine/src/evaluate/block.rs index 69e86665125f..dc8531187742 100644 --- a/crates/nu-engine/src/evaluate/block.rs +++ b/crates/nu-engine/src/evaluate/block.rs @@ -8,7 +8,7 @@ use nu_protocol::hir::{ }; use nu_protocol::{ReturnSuccess, UntaggedValue, Value}; use nu_source::{Span, Tag}; -use nu_stream::ToOutputStreamWithActions; +use nu_stream::ToActionStream; use nu_stream::{InputStream, OutputStream}; use std::sync::atomic::Ordering; @@ -80,7 +80,7 @@ pub fn run_block( match output { Ok(inp) if inp.is_empty() => {} Ok(inp) => { - let mut output_stream = inp.to_output_stream_with_actions(); + let mut output_stream = inp.to_action_stream(); match output_stream.next() { Some(Ok(ReturnSuccess::Value(Value { diff --git a/crates/nu-engine/src/filesystem/filesystem_shell.rs b/crates/nu-engine/src/filesystem/filesystem_shell.rs index 8892cdc2d8e3..bce9720e268f 100644 --- a/crates/nu-engine/src/filesystem/filesystem_shell.rs +++ b/crates/nu-engine/src/filesystem/filesystem_shell.rs @@ -9,7 +9,7 @@ use encoding_rs::Encoding; use nu_data::config::LocalConfigDiff; use nu_protocol::{CommandAction, ConfigPath, TaggedDictBuilder, Value}; use nu_source::{Span, Tag}; -use nu_stream::{ActionStream, Interruptible, ToOutputStreamWithActions}; +use nu_stream::{ActionStream, Interruptible, ToActionStream}; use std::collections::VecDeque; use std::io::{Error, ErrorKind}; use std::path::{Path, PathBuf}; @@ -222,7 +222,7 @@ impl Shell for FilesystemShell { Some(entry) }) .interruptible(ctrl_c_copy) - .to_output_stream_with_actions()) + .to_action_stream()) } fn cd(&self, args: CdArgs, name: Tag) -> Result { @@ -758,7 +758,7 @@ impl Shell for FilesystemShell { )) } }) - .to_output_stream_with_actions()) + .to_action_stream()) } fn path(&self) -> String { diff --git a/crates/nu-engine/src/plugin/run_plugin.rs b/crates/nu-engine/src/plugin/run_plugin.rs index d8f4569d8a81..a083c0c4b8e2 100644 --- a/crates/nu-engine/src/plugin/run_plugin.rs +++ b/crates/nu-engine/src/plugin/run_plugin.rs @@ -6,7 +6,7 @@ use log::trace; use nu_errors::ShellError; use nu_plugin::jsonrpc::JsonRpc; use nu_protocol::{Primitive, ReturnValue, Signature, UntaggedValue, Value}; -use nu_stream::{ActionStream, ToOutputStreamWithActions}; +use nu_stream::{ActionStream, ToActionStream}; use serde::{self, Deserialize, Serialize}; use std::collections::VecDeque; use std::io::prelude::*; @@ -201,12 +201,10 @@ fn run_filter(path: String, args: CommandArgs) -> Result match params { - Ok(params) => { - params.into_iter().to_output_stream_with_actions() + Ok(params) => params.into_iter().to_action_stream(), + Err(e) => { + vec![ReturnValue::Err(e)].into_iter().to_action_stream() } - Err(e) => vec![ReturnValue::Err(e)] - .into_iter() - .to_output_stream_with_actions(), }, Err(e) => ActionStream::one(Err( @@ -264,19 +262,17 @@ fn run_filter(path: String, args: CommandArgs) -> Result match params { - Ok(params) => { - params.into_iter().to_output_stream_with_actions() + Ok(params) => params.into_iter().to_action_stream(), + Err(e) => { + vec![ReturnValue::Err(e)].into_iter().to_action_stream() } - Err(e) => vec![ReturnValue::Err(e)] - .into_iter() - .to_output_stream_with_actions(), }, Err(e) => vec![Err(ShellError::untagged_runtime_error(format!( "Error while processing end_filter response: {:?} {}", e, input )))] .into_iter() - .to_output_stream_with_actions(), + .to_action_stream(), } } Err(e) => vec![Err(ShellError::untagged_runtime_error(format!( @@ -284,7 +280,7 @@ fn run_filter(path: String, args: CommandArgs) -> Result Result match params { - Ok(params) => { - params.into_iter().to_output_stream_with_actions() + Ok(params) => params.into_iter().to_action_stream(), + Err(e) => { + vec![ReturnValue::Err(e)].into_iter().to_action_stream() } - Err(e) => vec![ReturnValue::Err(e)] - .into_iter() - .to_output_stream_with_actions(), }, Err(e) => ActionStream::one(Err( ShellError::untagged_runtime_error(format!( @@ -363,7 +357,7 @@ fn run_filter(path: String, args: CommandArgs) -> Result ActionStream; +pub trait ToActionStream { + fn to_action_stream(self) -> ActionStream; } -impl ToOutputStreamWithActions for T +impl ToActionStream for T where T: Iterator + Send + Sync + 'static, U: Into, { - fn to_output_stream_with_actions(self) -> ActionStream { + fn to_action_stream(self) -> ActionStream { ActionStream { values: Box::new(self.map(|item| item.into())), } From 758f29901596d055773ccce9d70a9875aa846cb4 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Mon, 12 Apr 2021 14:04:13 +1200 Subject: [PATCH 5/5] Fmt --- crates/nu-command/src/commands/cal.rs | 4 +--- crates/nu-command/src/commands/each/group.rs | 4 +--- crates/nu-command/src/examples/double_echo.rs | 3 +-- crates/nu-command/src/prelude.rs | 2 +- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/crates/nu-command/src/commands/cal.rs b/crates/nu-command/src/commands/cal.rs index 0bc66ed37c2b..fb56c01a2513 100644 --- a/crates/nu-command/src/commands/cal.rs +++ b/crates/nu-command/src/commands/cal.rs @@ -101,9 +101,7 @@ pub fn cal(args: CommandArgs) -> Result { current_day_option, )?; - Ok(calendar_vec_deque - .into_iter() - .to_action_stream()) + Ok(calendar_vec_deque.into_iter().to_action_stream()) } fn get_invalid_year_shell_error(year_tag: &Tag) -> ShellError { diff --git a/crates/nu-command/src/commands/each/group.rs b/crates/nu-command/src/commands/each/group.rs index a9e4fd37483b..2dde29ef55d1 100644 --- a/crates/nu-command/src/commands/each/group.rs +++ b/crates/nu-command/src/commands/each/group.rs @@ -54,9 +54,7 @@ impl WholeStreamCommand for EachGroup { input, }; - Ok(each_group_iterator - .flatten() - .to_action_stream()) + Ok(each_group_iterator.flatten().to_action_stream()) } } diff --git a/crates/nu-command/src/examples/double_echo.rs b/crates/nu-command/src/examples/double_echo.rs index 65524132137f..745d688bdc75 100644 --- a/crates/nu-command/src/examples/double_echo.rs +++ b/crates/nu-command/src/examples/double_echo.rs @@ -60,8 +60,7 @@ impl WholeStreamCommand for Command { let subtable = vec![UntaggedValue::Table(values).into_value(base_value.tag())]; - (subtable.into_iter().map(ReturnSuccess::value)) - .to_action_stream() + (subtable.into_iter().map(ReturnSuccess::value)).to_action_stream() } else { (table .into_iter() diff --git a/crates/nu-command/src/prelude.rs b/crates/nu-command/src/prelude.rs index 7bad251fb361..a4c2b541764f 100644 --- a/crates/nu-command/src/prelude.rs +++ b/crates/nu-command/src/prelude.rs @@ -23,7 +23,7 @@ pub(crate) use nu_parser::ParserScope; pub(crate) use nu_protocol::{out, row}; pub(crate) use nu_source::{AnchorLocation, PrettyDebug, Span, SpannedItem, Tag, TaggedItem}; pub(crate) use nu_stream::{ActionStream, InputStream, Interruptible, OutputStream}; -pub(crate) use nu_stream::{ToInputStream, ToOutputStream, ToActionStream}; +pub(crate) use nu_stream::{ToActionStream, ToInputStream, ToOutputStream}; pub(crate) use nu_value_ext::ValueExt; pub(crate) use num_bigint::BigInt; pub(crate) use num_traits::cast::ToPrimitive;