forked from extern/nushell
Display built features. Long/Short commit hashes display removed due to cargo publishing. (#2333)
Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com> Co-authored-by: Jonathan Turner <jonathandturner@users.noreply.github.com> Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com> Co-authored-by: Jonathan Turner <jonathandturner@users.noreply.github.com>
This commit is contained in:
parent
0194dee3a6
commit
e372e7c448
@ -52,7 +52,6 @@ ical = "0.6.*"
|
|||||||
ichwh = {version = "0.3.4", optional = true}
|
ichwh = {version = "0.3.4", optional = true}
|
||||||
indexmap = {version = "1.4.0", features = ["serde-1"]}
|
indexmap = {version = "1.4.0", features = ["serde-1"]}
|
||||||
itertools = "0.9.0"
|
itertools = "0.9.0"
|
||||||
last-git-commit = "0.2.0"
|
|
||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
meval = "0.2"
|
meval = "0.2"
|
||||||
natural = "0.5.0"
|
natural = "0.5.0"
|
||||||
@ -115,7 +114,6 @@ optional = true
|
|||||||
version = "0.23.1"
|
version = "0.23.1"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
git2 = "0.13"
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
quickcheck = "0.9"
|
quickcheck = "0.9"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::commands::WholeStreamCommand;
|
use crate::commands::WholeStreamCommand;
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
use crate::TaggedListBuilder;
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
use last_git_commit::LastGitCommit;
|
|
||||||
use nu_errors::ShellError;
|
use nu_errors::ShellError;
|
||||||
use nu_protocol::{Dictionary, Signature, UntaggedValue};
|
use nu_protocol::{Dictionary, Signature, UntaggedValue};
|
||||||
|
|
||||||
@ -41,28 +41,42 @@ impl WholeStreamCommand for Version {
|
|||||||
pub fn version(args: CommandArgs, _registry: &CommandRegistry) -> Result<OutputStream, ShellError> {
|
pub fn version(args: CommandArgs, _registry: &CommandRegistry) -> Result<OutputStream, ShellError> {
|
||||||
let tag = args.call_info.args.span;
|
let tag = args.call_info.args.span;
|
||||||
|
|
||||||
let mut indexmap = IndexMap::with_capacity(3);
|
let mut indexmap = IndexMap::with_capacity(4);
|
||||||
|
|
||||||
indexmap.insert(
|
indexmap.insert(
|
||||||
"version".to_string(),
|
"version".to_string(),
|
||||||
UntaggedValue::string(clap::crate_version!()).into_value(&tag),
|
UntaggedValue::string(clap::crate_version!()).into_value(&tag),
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Ok(lgc) = LastGitCommit::new().build() {
|
indexmap.insert("features".to_string(), features_enabled(&tag).into_value());
|
||||||
indexmap.insert(
|
|
||||||
"short_commit_hash".to_string(),
|
|
||||||
UntaggedValue::string(lgc.id().short()).into_value(&tag),
|
|
||||||
);
|
|
||||||
indexmap.insert(
|
|
||||||
"long_commit_hash".to_string(),
|
|
||||||
UntaggedValue::string(lgc.id().long()).into_value(&tag),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
let value = UntaggedValue::Row(Dictionary::from(indexmap)).into_value(&tag);
|
let value = UntaggedValue::Row(Dictionary::from(indexmap)).into_value(&tag);
|
||||||
Ok(OutputStream::one(value))
|
Ok(OutputStream::one(value))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn features_enabled(tag: impl Into<Tag>) -> TaggedListBuilder {
|
||||||
|
let mut names = TaggedListBuilder::new(tag);
|
||||||
|
|
||||||
|
names.push_untagged(UntaggedValue::string("default"));
|
||||||
|
|
||||||
|
#[cfg(feature = "clipboard-cli")]
|
||||||
|
{
|
||||||
|
names.push_untagged(UntaggedValue::string("clipboard"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "trash-support")]
|
||||||
|
{
|
||||||
|
names.push_untagged(UntaggedValue::string("trash"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "starship-prompt")]
|
||||||
|
{
|
||||||
|
names.push_untagged(UntaggedValue::string("starship"));
|
||||||
|
}
|
||||||
|
|
||||||
|
names
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::Version;
|
use super::Version;
|
||||||
|
Loading…
Reference in New Issue
Block a user