From 1c2cc8f1fefdb32f1c0441a4c79160466b071698 Mon Sep 17 00:00:00 2001 From: yourfriendoss Date: Sun, 14 Sep 2025 17:04:01 +0300 Subject: [PATCH] feat: show children --- src/commands/system/help.rs | 45 +++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/src/commands/system/help.rs b/src/commands/system/help.rs index bf3e41a..b48b3c9 100644 --- a/src/commands/system/help.rs +++ b/src/commands/system/help.rs @@ -19,6 +19,38 @@ impl HelpCommand { } } +fn format_argument_spec(arg: &ArgumentSpec) -> String { + let argument_brackets = if arg.required { + ("(", "*)") + } else { + ("(", ")") + }; + + let mut s = String::new(); + + if let ArgumentType::Enum(possibilities) = &arg.arg_type { + s.push_str(argument_brackets.0); + s.push_str(&possibilities.to_vec().join("|")); + } else { + s.push_str(argument_brackets.0); + s.push_str(arg.name); + } + + if !arg.children.is_empty() { + let children_str = arg + .children + .iter() + .map(format_argument_spec) + .collect::>() + .join(" "); + s.push(' '); + s.push_str(&children_str); + } + + s.push_str(argument_brackets.1); + s +} + #[async_trait] impl Command for HelpCommand { fn name(&self) -> &'static str { @@ -58,18 +90,7 @@ impl Command for HelpCommand { let mut arg_string: Vec = Vec::new(); for arg in cmd.argument_spec() { - let argument_brackets = { - if arg.required { - ("(", "*)") - } else { - ("(", ")") - } - }; - - arg_string.push(format!( - "{}{}{}", - argument_brackets.0, arg.name, argument_brackets.1 - )); + arg_string.push(format_argument_spec(arg)); } format!(