aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/src/program/exec.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-04-11 16:50:57 +0800
committer魏曹先生 <1992414357@qq.com>2026-04-11 16:50:57 +0800
commit58ef8a8f42a68c7a81118ef9120705730ce3f458 (patch)
tree80f302b07f011d2e636f5f8d3ec815fe6a4dafab /mingling_core/src/program/exec.rs
parent839326946560166da84c04d4770385795d96cff0 (diff)
Add shell completion script generation feature
Diffstat (limited to 'mingling_core/src/program/exec.rs')
-rw-r--r--mingling_core/src/program/exec.rs23
1 files changed, 2 insertions, 21 deletions
diff --git a/mingling_core/src/program/exec.rs b/mingling_core/src/program/exec.rs
index f578064..072f4cb 100644
--- a/mingling_core/src/program/exec.rs
+++ b/mingling_core/src/program/exec.rs
@@ -73,14 +73,14 @@ where
/// Match user input against registered dispatchers and return the matched dispatcher and remaining arguments.
#[allow(clippy::type_complexity)]
-fn match_user_input<C, G>(
+pub fn match_user_input<C, G>(
program: &Program<C, G>,
) -> Result<(&Box<dyn Dispatcher<G> + Send + Sync>, Vec<String>), ProgramInternalExecuteError>
where
C: ProgramCollect<Enum = G>,
G: Display,
{
- let nodes = get_nodes(program);
+ let nodes = program.get_nodes();
let command = format!("{} ", program.args.join(" "));
// Find all nodes that match the command prefix
@@ -140,22 +140,3 @@ fn render<C: ProgramCollect<Enum = G>, G: Display>(
}
}
}
-
-// Get all registered dispatcher names from the program
-fn get_nodes<C: ProgramCollect<Enum = G>, G: Display>(
- program: &Program<C, G>,
-) -> Vec<(String, &Box<dyn Dispatcher<G> + Send + Sync>)> {
- program
- .dispatcher
- .iter()
- .map(|disp| {
- let node_str = disp
- .node()
- .to_string()
- .split('.')
- .collect::<Vec<_>>()
- .join(" ");
- (node_str, disp)
- })
- .collect()
-}