From 3bbb64d0652ccf9f51de901e8206c4f665c4d07b Mon Sep 17 00:00:00 2001 From: Jeff Date: Mon, 28 Aug 2023 17:58:35 -0400 Subject: [PATCH] Add filtering help by group --- src/tools/general.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/tools/general.rs b/src/tools/general.rs index 016cf1e..48fa42a 100644 --- a/src/tools/general.rs +++ b/src/tools/general.rs @@ -19,12 +19,33 @@ impl Tool for Help { fn run(&self, argument: &Value) -> Result { self.check_type(argument)?; - let mut table = Table::new(vec!["tool".to_string(), "description".to_string()]); + let mut table = Table::new(vec![ + "tool".to_string(), + "description".to_string(), + "group".to_string(), + "inputs".to_string(), + ]); for tool in TOOL_LIST { + let tool_group = tool.info().group.to_string(); + + if let Ok(group) = argument.as_string() { + if &tool_group != group { + continue; + } + } + let row = vec![ Value::String(tool.info().identifier.to_string()), Value::String(tool.info().description.to_string()), + Value::String(tool_group), + Value::List( + tool.info() + .inputs + .iter() + .map(|value_type| Value::String(value_type.to_string())) + .collect(), + ), ]; table.insert(row)?;