2020-05-04 10:44:33 +02:00
|
|
|
use crate::commands::WholeStreamCommand;
|
|
|
|
use crate::prelude::*;
|
|
|
|
use nu_errors::ShellError;
|
2020-05-16 05:18:24 +02:00
|
|
|
use nu_protocol::{ReturnSuccess, Signature, UntaggedValue};
|
2020-05-04 10:44:33 +02:00
|
|
|
|
2020-05-16 05:18:24 +02:00
|
|
|
#[derive(Clone)]
|
2020-05-04 10:44:33 +02:00
|
|
|
pub struct To;
|
|
|
|
|
|
|
|
impl WholeStreamCommand for To {
|
|
|
|
fn name(&self) -> &str {
|
|
|
|
"to"
|
|
|
|
}
|
|
|
|
|
|
|
|
fn signature(&self) -> Signature {
|
|
|
|
Signature::build("to")
|
|
|
|
}
|
|
|
|
|
|
|
|
fn usage(&self) -> &str {
|
2020-05-04 23:00:29 +02:00
|
|
|
"Convert table into an output format (based on subcommand, like csv, html, json, yaml)."
|
2020-05-04 10:44:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fn run(
|
|
|
|
&self,
|
|
|
|
_args: CommandArgs,
|
|
|
|
registry: &CommandRegistry,
|
|
|
|
) -> Result<OutputStream, ShellError> {
|
2020-05-16 05:18:24 +02:00
|
|
|
let registry = registry.clone();
|
|
|
|
let stream = async_stream! {
|
|
|
|
yield Ok(ReturnSuccess::Value(
|
|
|
|
UntaggedValue::string(crate::commands::help::get_help(&To, ®istry))
|
|
|
|
.into_value(Tag::unknown()),
|
|
|
|
));
|
|
|
|
};
|
|
|
|
|
|
|
|
Ok(stream.to_output_stream())
|
2020-05-04 10:44:33 +02:00
|
|
|
}
|
|
|
|
}
|