* Moves off of draining between filters. Instead, the sink will pull on the stream, and will drain element-wise. This moves the whole stream to being lazy. * Adds ctrl-c support and connects it into some of the key points where we pull on the stream. If a ctrl-c is detect, we immediately halt pulling on the stream and return to the prompt. * Moves away from having a SourceMap where anchor locations are stored. Now AnchorLocation is kept directly in the Tag. * To make this possible, split tag and span. Span is largely used in the parser and is copyable. Tag is now no longer copyable.
45 lines
1.1 KiB
Rust
45 lines
1.1 KiB
Rust
use crate::commands::WholeStreamCommand;
|
|
use crate::data::{Dictionary, Value};
|
|
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(),
|
|
Value::string(clap::crate_version!()).tagged(&tag),
|
|
);
|
|
|
|
let value = Value::Row(Dictionary::from(indexmap)).tagged(&tag);
|
|
Ok(OutputStream::one(value))
|
|
}
|