From 13257004bcd0a4d4e80e043f4b57436cc8a62441 Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Thu, 3 Jun 2021 08:53:32 -0500 Subject: [PATCH] add list of installed plugins to version command (#3548) --- Cargo.lock | 4 +-- crates/nu-command/src/commands/version.rs | 37 +++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e47fce8204..0a510e2283 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -827,7 +827,7 @@ checksum = "e68bbd985a63de680ab4d1ad77b6306611a8f961b282c8b5ab513e6de934e396" dependencies = [ "cfg-if 1.0.0", "libc", - "serde 1.0.125", + "serde 1.0.126", "winapi 0.3.9", ] @@ -2137,7 +2137,7 @@ dependencies = [ "proc-macro-hack", "proc-macro2", "quote 1.0.9", - "syn 1.0.71", + "syn 1.0.72", ] [[package]] diff --git a/crates/nu-command/src/commands/version.rs b/crates/nu-command/src/commands/version.rs index f7b668d044..5b4e781802 100644 --- a/crates/nu-command/src/commands/version.rs +++ b/crates/nu-command/src/commands/version.rs @@ -140,6 +140,43 @@ pub fn version(args: CommandArgs) -> Result { features_enabled().join(", ").to_string_value_create_tag(), ); + // Manually create a list of all possible plugin names + let all_plugins = vec![ + "fetch", + "inc", + "match", + "post", + "ps", + "sys", + "textview", + "binaryview", + "chart bar", + "chart line", + "from bson", + "from sqlite", + "query json", + "s3", + "selector", + "start", + "to bson", + "to sqlite", + "tree", + "xpath", + ]; + + // Get a list of command names and check for plugins + let installed_plugins = args + .scope() + .get_command_names() + .into_iter() + .filter(|cmd| all_plugins.contains(&cmd.as_str())) + .collect::>(); + + indexmap.insert( + "installed_plugins".to_string(), + installed_plugins.join(", ").to_string_value_create_tag(), + ); + let value = UntaggedValue::Row(Dictionary::from(indexmap)).into_value(&tag); Ok(ActionStream::one(value)) }