2019-08-19 03:30:29 +02:00
|
|
|
use crate::commands::WholeStreamCommand;
|
2019-11-21 15:33:14 +01:00
|
|
|
use crate::data::Dictionary;
|
2019-09-11 16:36:50 +02:00
|
|
|
use crate::errors::ShellError;
|
2019-08-19 03:30:29 +02:00
|
|
|
use crate::parser::registry::Signature;
|
|
|
|
use crate::prelude::*;
|
|
|
|
use indexmap::IndexMap;
|
|
|
|
|
|
|
|
pub struct Version;
|
|
|
|
|
|
|
|
impl WholeStreamCommand for Version {
|
|
|
|
fn name(&self) -> &str {
|
|
|
|
"version"
|
|
|
|
}
|
|
|
|
|
|
|
|
fn signature(&self) -> Signature {
|
|
|
|
Signature::build("version")
|
|
|
|
}
|
2019-08-30 00:52:32 +02:00
|
|
|
|
|
|
|
fn usage(&self) -> &str {
|
|
|
|
"Display Nu version"
|
|
|
|
}
|
|
|
|
|
|
|
|
fn run(
|
|
|
|
&self,
|
|
|
|
args: CommandArgs,
|
|
|
|
registry: &CommandRegistry,
|
|
|
|
) -> Result<OutputStream, ShellError> {
|
|
|
|
date(args, registry)
|
|
|
|
}
|
2019-08-19 03:30:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn date(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream, ShellError> {
|
|
|
|
let args = args.evaluate_once(registry)?;
|
2019-10-13 06:12:43 +02:00
|
|
|
let tag = args.call_info.name_tag.clone();
|
2019-08-19 03:30:29 +02:00
|
|
|
|
|
|
|
let mut indexmap = IndexMap::new();
|
|
|
|
indexmap.insert(
|
|
|
|
"version".to_string(),
|
2019-11-21 15:33:14 +01:00
|
|
|
UntaggedValue::string(clap::crate_version!()).into_value(&tag),
|
2019-08-19 03:30:29 +02:00
|
|
|
);
|
|
|
|
|
2019-11-21 15:33:14 +01:00
|
|
|
let value = UntaggedValue::Row(Dictionary::from(indexmap)).into_value(&tag);
|
2019-08-19 03:30:29 +02:00
|
|
|
Ok(OutputStream::one(value))
|
|
|
|
}
|