From bcfb084d4c3987480f8a8bf4e2e449f237459477 Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Sat, 13 Jun 2020 12:30:24 -0400 Subject: [PATCH] Remove async_stream from some commands (#1976) --- crates/nu-cli/src/commands/str_/command.rs | 11 ++++------- crates/nu-cli/src/commands/to_tsv.rs | 23 +++++----------------- 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/crates/nu-cli/src/commands/str_/command.rs b/crates/nu-cli/src/commands/str_/command.rs index c97a20b81d..210ece0d6e 100644 --- a/crates/nu-cli/src/commands/str_/command.rs +++ b/crates/nu-cli/src/commands/str_/command.rs @@ -28,14 +28,11 @@ impl WholeStreamCommand for Command { registry: &CommandRegistry, ) -> Result { let registry = registry.clone(); - let stream = async_stream! { - yield Ok(ReturnSuccess::Value( - UntaggedValue::string(crate::commands::help::get_help(&Command, ®istry)) - .into_value(Tag::unknown()), - )); - }; - Ok(stream.to_output_stream()) + Ok(OutputStream::one(ReturnSuccess::value( + UntaggedValue::string(crate::commands::help::get_help(&Command, ®istry)) + .into_value(Tag::unknown()), + ))) } } diff --git a/crates/nu-cli/src/commands/to_tsv.rs b/crates/nu-cli/src/commands/to_tsv.rs index 45b365736f..e77c0858ff 100644 --- a/crates/nu-cli/src/commands/to_tsv.rs +++ b/crates/nu-cli/src/commands/to_tsv.rs @@ -34,29 +34,16 @@ impl WholeStreamCommand for ToTSV { args: CommandArgs, registry: &CommandRegistry, ) -> Result { - to_tsv(args, registry) + to_tsv(args, registry).await } } -fn to_tsv(args: CommandArgs, registry: &CommandRegistry) -> Result { +async fn to_tsv(args: CommandArgs, registry: &CommandRegistry) -> Result { let registry = registry.clone(); - let stream = async_stream! { - let name = args.call_info.name_tag.clone(); - let (ToTSVArgs { headerless }, mut input) = args.process(®istry).await?; - let mut result = to_delimited_data( - headerless, - '\t', - "TSV", - input, - name, - )?; + let name = args.call_info.name_tag.clone(); + let (ToTSVArgs { headerless }, input) = args.process(®istry).await?; - while let Some(item) = result.next().await { - yield item; - } - }; - - Ok(stream.to_output_stream()) + to_delimited_data(headerless, '\t', "TSV", input, name) } #[cfg(test)]