From c4f376b9c3319c9dc2b8e8cd621cb324ac3e83ce Mon Sep 17 00:00:00 2001 From: Sofia Date: Wed, 15 Jul 2026 20:32:20 +0300 Subject: [PATCH] Improve help command --- rust/src/ui/cli.rs | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/rust/src/ui/cli.rs b/rust/src/ui/cli.rs index 5c770e7..945325e 100644 --- a/rust/src/ui/cli.rs +++ b/rust/src/ui/cli.rs @@ -118,13 +118,24 @@ trait Command { struct HelpCommand; impl Command for HelpCommand { fn execute(&self, cli: &mut CommandLinePanel, params: &[&str]) { - let mut keys = cli.commands.keys().cloned().collect::>(); - keys.sort(); - for key in keys { - cli.publish_message( - format!("\t- {}: {}", key, cli.commands.get(&key).unwrap().help()), - CliColor::Regular, - ); + if let Some(command_name) = params.first() { + if let Some(command) = cli.commands.get(*command_name) { + cli.publish_message(command.help().to_string(), CliColor::Regular); + } else { + cli.publish_message( + format!("Unknown command: {}", command_name), + CliColor::Regular, + ); + } + } else { + let mut keys = cli.commands.keys().cloned().collect::>(); + keys.sort(); + for key in keys { + cli.publish_message( + format!("\t- {}: {}", key, cli.commands.get(&key).unwrap().help()), + CliColor::Regular, + ); + } } }