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,
) -> Result<OutputStream, ShellError> {
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,
registry: &CommandRegistry,
) -> 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 stream = async_stream! {
let name = args.call_info.name_tag.clone();
let (ToTSVArgs { headerless }, mut input) = args.process(&registry).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(&registry).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)]