From 1eb5306fe6e0e09970b37d267051589d8133a824 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sat, 11 Apr 2026 18:29:57 +0800 Subject: Implement basic command completion with shell support --- mingling_core/src/program/exec.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'mingling_core/src/program/exec.rs') diff --git a/mingling_core/src/program/exec.rs b/mingling_core/src/program/exec.rs index 072f4cb..71d73e6 100644 --- a/mingling_core/src/program/exec.rs +++ b/mingling_core/src/program/exec.rs @@ -21,7 +21,7 @@ where let mut stop_next = false; // Match user input - match match_user_input(&program) { + match match_user_input(&program, program.args.clone()) { Ok((dispatcher, args)) => { // Entry point current = match dispatcher.begin(args) { @@ -75,13 +75,14 @@ where #[allow(clippy::type_complexity)] pub fn match_user_input( program: &Program, + args: Vec, ) -> Result<(&Box + Send + Sync>, Vec), ProgramInternalExecuteError> where C: ProgramCollect, G: Display, { let nodes = program.get_nodes(); - let command = format!("{} ", program.args.join(" ")); + let command = format!("{} ", args.join(" ")); // Find all nodes that match the command prefix let matching_nodes: Vec<&(String, &Box + Send + Sync>)> = nodes @@ -98,7 +99,7 @@ where 1 => { let matched_prefix = matching_nodes[0]; let prefix_len = matched_prefix.0.split_whitespace().count(); - let trimmed_args: Vec = program.args.iter().skip(prefix_len).cloned().collect(); + let trimmed_args: Vec = args.iter().skip(prefix_len).cloned().collect(); Ok((matched_prefix.1, trimmed_args)) } _ => { @@ -110,7 +111,7 @@ where .unwrap(); let prefix_len = matched_prefix.0.split_whitespace().count(); - let trimmed_args: Vec = program.args.iter().skip(prefix_len).cloned().collect(); + let trimmed_args: Vec = args.iter().skip(prefix_len).cloned().collect(); Ok((matched_prefix.1, trimmed_args)) } } -- cgit