summaryrefslogtreecommitdiff
path: root/src/systems/cmd/processer.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-02-25 10:58:39 +0800
committer魏曹先生 <1992414357@qq.com>2026-02-25 10:58:39 +0800
commit6bd344793e5c2e84361475d6e221007ef21faaad (patch)
tree4d2cb4148b534381b5d110b97a690d8bfd921855 /src/systems/cmd/processer.rs
parent5f3d4892a12189e88e692eabdd5f8fe68c79b23e (diff)
Remove ambiguous command error and auto-select longest match
Diffstat (limited to 'src/systems/cmd/processer.rs')
-rw-r--r--src/systems/cmd/processer.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/systems/cmd/processer.rs b/src/systems/cmd/processer.rs
index 4bcaaeb..196764a 100644
--- a/src/systems/cmd/processer.rs
+++ b/src/systems/cmd/processer.rs
@@ -37,12 +37,11 @@ pub async fn jv_cmd_process(
}
_ => {
// Multiple matching nodes found
- return Err(CmdProcessError::AmbiguousCommand(
- matching_nodes
- .iter()
- .map(|s| s.to_string())
- .collect::<Vec<String>>(),
- ));
+ // Find the node with the longest length (most specific match)
+ let matched_prefix = matching_nodes.iter().max_by_key(|node| node.len()).unwrap();
+ let prefix_len = matched_prefix.split_whitespace().count();
+ let trimmed_args: Vec<String> = args.into_iter().cloned().skip(prefix_len).collect();
+ return jv_cmd_process_node(matched_prefix, trimmed_args, ctx, renderer_override).await;
}
}
}