mirror of
https://github.com/nushell/nushell.git
synced 2024-12-12 18:20:55 +01:00
b2c5af457e
This improves incremental build time when working on what was previously the root package. For example, previously all plugins would be rebuilt with a change to `src/commands/classified/external.rs`, but now only `nu-cli` will have to be rebuilt (and anything that depends on it).
44 lines
1.1 KiB
Rust
44 lines
1.1 KiB
Rust
use crate::commands::WholeStreamCommand;
|
|
use crate::prelude::*;
|
|
use indexmap::IndexMap;
|
|
use nu_errors::ShellError;
|
|
use nu_protocol::{Dictionary, Signature, UntaggedValue};
|
|
|
|
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> {
|
|
version(args, registry)
|
|
}
|
|
}
|
|
|
|
pub fn version(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))
|
|
}
|