From dc9b7b3e6bd08a3f6b1f25bb897dcd2ac42989a5 Mon Sep 17 00:00:00 2001 From: dawn <90008@gaze.systems> Date: Sun, 18 Jan 2026 23:34:58 +0300 Subject: [PATCH] use original command when ranking for possible commands if the command was from an optional branch --- crates/command_definitions/src/system.rs | 8 +++++--- crates/command_parser/src/lib.rs | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/command_definitions/src/system.rs b/crates/command_definitions/src/system.rs index d2d4fc35..60c9a2cc 100644 --- a/crates/command_definitions/src/system.rs +++ b/crates/command_definitions/src/system.rs @@ -246,9 +246,11 @@ pub fn edit() -> impl Iterator { ] .map(apply_list_opts); - let system_groups_cmd = - once(command!(system, Optional(SystemRef), "groups", search_param => "system_groups")) - .map(apply_list_opts); + let system_groups_cmd = once( + command!(system, Optional(SystemRef), "groups", search_param => "system_groups") + .help("Lists groups in a system"), + ) + .map(apply_list_opts); let system_display_id_cmd = once( command!(system, Optional(SystemRef), "id" => "system_display_id") diff --git a/crates/command_parser/src/lib.rs b/crates/command_parser/src/lib.rs index e1b5b79b..c6322ddd 100644 --- a/crates/command_parser/src/lib.rs +++ b/crates/command_parser/src/lib.rs @@ -219,7 +219,7 @@ pub fn parse_command( } } } - + let full_cmd = command.original.as_deref().unwrap_or(&command); if misplaced_flags.is_empty().not() { let mut error = format!( @@ -346,6 +346,7 @@ fn rank_possible_commands( ) -> Vec<(Command, String, bool)> { let mut commands_with_scores: Vec<(&Command, String, f64, bool)> = possible_commands .into_iter() + .map(|cmd| cmd.original.as_deref().unwrap_or(cmd)) .filter(|cmd| cmd.show_in_suggestions) .flat_map(|cmd| { let versions = generate_command_versions(cmd);