This commit extracts Tag, Span, Text, as well as source-related debug facilities into a new crate called nu_source. This change is much bigger than one might have expected because the previous code relied heavily on implementing inherent methods on `Tagged<T>` and `Spanned<T>`, which is no longer possible. As a result, this change creates more concrete types instead of using `Tagged<T>`. One notable example: Tagged<Value> became Value, and Value became UntaggedValue. This change clarifies the intent of the code in many places, but it does make it a big change.
45 lines
1.1 KiB
Rust
45 lines
1.1 KiB
Rust
use crate::commands::WholeStreamCommand;
|
|
use crate::data::Dictionary;
|
|
use crate::errors::ShellError;
|
|
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")
|
|
}
|
|
|
|
fn usage(&self) -> &str {
|
|
"Display Nu version"
|
|
}
|
|
|
|
fn run(
|
|
&self,
|
|
args: CommandArgs,
|
|
registry: &CommandRegistry,
|
|
) -> Result<OutputStream, ShellError> {
|
|
date(args, registry)
|
|
}
|
|
}
|
|
|
|
pub fn date(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream, ShellError> {
|
|
let args = args.evaluate_once(registry)?;
|
|
let tag = args.call_info.name_tag.clone();
|
|
|
|
let mut indexmap = IndexMap::new();
|
|
indexmap.insert(
|
|
"version".to_string(),
|
|
UntaggedValue::string(clap::crate_version!()).into_value(&tag),
|
|
);
|
|
|
|
let value = UntaggedValue::Row(Dictionary::from(indexmap)).into_value(&tag);
|
|
Ok(OutputStream::one(value))
|
|
}
|