Remove async_stream from some commands (#1976)

This commit is contained in:
Joseph T. Lyons 2020-06-13 12:30:24 -04:00 committed by GitHub
parent a1fd5ad128
commit bcfb084d4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 25 deletions

View File

@ -28,14 +28,11 @@ impl WholeStreamCommand for Command {
registry: &CommandRegistry, registry: &CommandRegistry,
) -> Result<OutputStream, ShellError> { ) -> Result<OutputStream, ShellError> {
let registry = registry.clone(); let registry = registry.clone();
let stream = async_stream! {
yield Ok(ReturnSuccess::Value(
UntaggedValue::string(crate::commands::help::get_help(&Command, &registry))
.into_value(Tag::unknown()),
));
};
Ok(stream.to_output_stream()) Ok(OutputStream::one(ReturnSuccess::value(
UntaggedValue::string(crate::commands::help::get_help(&Command, &registry))
.into_value(Tag::unknown()),
)))
} }
} }

View File

@ -34,29 +34,16 @@ impl WholeStreamCommand for ToTSV {
args: CommandArgs, args: CommandArgs,
registry: &CommandRegistry, registry: &CommandRegistry,
) -> Result<OutputStream, ShellError> { ) -> Result<OutputStream, ShellError> {
to_tsv(args, registry) to_tsv(args, registry).await
} }
} }
fn to_tsv(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream, ShellError> { async fn to_tsv(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream, ShellError> {
let registry = registry.clone(); let registry = registry.clone();
let stream = async_stream! { let name = args.call_info.name_tag.clone();
let name = args.call_info.name_tag.clone(); let (ToTSVArgs { headerless }, input) = args.process(&registry).await?;
let (ToTSVArgs { headerless }, mut input) = args.process(&registry).await?;
let mut result = to_delimited_data(
headerless,
'\t',
"TSV",
input,
name,
)?;
while let Some(item) = result.next().await { to_delimited_data(headerless, '\t', "TSV", input, name)
yield item;
}
};
Ok(stream.to_output_stream())
} }
#[cfg(test)] #[cfg(test)]