forked from extern/nushell
Add commit hash to version command (#2312)
* Add commit to version command * Replace unwrap with expect.
This commit is contained in:
@ -4,6 +4,8 @@ use indexmap::IndexMap;
|
||||
use nu_errors::ShellError;
|
||||
use nu_protocol::{Dictionary, Signature, UntaggedValue};
|
||||
|
||||
const GIT_COMMIT_HASH: &str = include_str!(concat!(env!("OUT_DIR"), "/git_commit_hash"));
|
||||
|
||||
pub struct Version;
|
||||
|
||||
#[async_trait]
|
||||
@ -40,11 +42,16 @@ impl WholeStreamCommand for Version {
|
||||
pub fn version(args: CommandArgs, _registry: &CommandRegistry) -> Result<OutputStream, ShellError> {
|
||||
let tag = args.call_info.args.span;
|
||||
|
||||
let mut indexmap = IndexMap::new();
|
||||
let mut indexmap = IndexMap::with_capacity(2);
|
||||
|
||||
indexmap.insert(
|
||||
"version".to_string(),
|
||||
UntaggedValue::string(clap::crate_version!()).into_value(&tag),
|
||||
);
|
||||
indexmap.insert(
|
||||
"commit_hash".to_string(),
|
||||
UntaggedValue::string(GIT_COMMIT_HASH).into_value(&tag),
|
||||
);
|
||||
|
||||
let value = UntaggedValue::Row(Dictionary::from(indexmap)).into_value(&tag);
|
||||
Ok(OutputStream::one(value))
|
||||
|
Reference in New Issue
Block a user