2020-05-04 10:44:33 +02:00
|
|
|
use crate::prelude::*;
|
2021-01-10 03:50:49 +01:00
|
|
|
use nu_engine::WholeStreamCommand;
|
2020-05-04 10:44:33 +02:00
|
|
|
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
|
|
|
|
|
|
|
pub struct From;
|
|
|
|
|
2020-05-29 10:22:52 +02:00
|
|
|
#[async_trait]
|
2020-05-04 10:44:33 +02:00
|
|
|
impl WholeStreamCommand for From {
|
|
|
|
fn name(&self) -> &str {
|
|
|
|
"from"
|
|
|
|
}
|
|
|
|
|
|
|
|
fn signature(&self) -> Signature {
|
|
|
|
Signature::build("from")
|
|
|
|
}
|
|
|
|
|
|
|
|
fn usage(&self) -> &str {
|
2020-05-04 23:00:29 +02:00
|
|
|
"Parse content (string or binary) as a table (input format based on subcommand, like csv, ini, json, toml)"
|
2020-05-04 10:44:33 +02:00
|
|
|
}
|
|
|
|
|
2020-12-18 08:53:49 +01:00
|
|
|
async fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
|
2020-06-12 10:34:41 +02:00
|
|
|
Ok(OutputStream::one(ReturnSuccess::value(
|
2021-01-10 03:50:49 +01:00
|
|
|
UntaggedValue::string(get_help(&From, &args.scope)).into_value(Tag::unknown()),
|
2020-06-12 10:34:41 +02:00
|
|
|
)))
|
2020-05-04 10:44:33 +02:00
|
|
|
}
|
|
|
|
}
|
2020-05-18 14:56:01 +02:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::From;
|
2020-10-03 16:06:02 +02:00
|
|
|
use super::ShellError;
|
2020-05-18 14:56:01 +02:00
|
|
|
|
|
|
|
#[test]
|
2020-10-03 16:06:02 +02:00
|
|
|
fn examples_work_as_expected() -> Result<(), ShellError> {
|
2020-05-18 14:56:01 +02:00
|
|
|
use crate::examples::test as test_examples;
|
|
|
|
|
2020-10-03 16:06:02 +02:00
|
|
|
Ok(test_examples(From {})?)
|
2020-05-18 14:56:01 +02:00
|
|
|
}
|
|
|
|
}
|