diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-04-11 16:50:57 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-04-11 16:50:57 +0800 |
| commit | 58ef8a8f42a68c7a81118ef9120705730ce3f458 (patch) | |
| tree | 80f302b07f011d2e636f5f8d3ec815fe6a4dafab /mingling_core/src/program.rs | |
| parent | 839326946560166da84c04d4770385795d96cff0 (diff) | |
Add shell completion script generation feature
Diffstat (limited to 'mingling_core/src/program.rs')
| -rw-r--r-- | mingling_core/src/program.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/mingling_core/src/program.rs b/mingling_core/src/program.rs index 7b9f8d4..42ca531 100644 --- a/mingling_core/src/program.rs +++ b/mingling_core/src/program.rs @@ -164,6 +164,11 @@ where } } } + + // Get all registered dispatcher names from the program + pub fn get_nodes(&self) -> Vec<(String, &Box<dyn Dispatcher<G> + Send + Sync>)> { + get_nodes(self) + } } /// Collected program context @@ -251,3 +256,22 @@ macro_rules! __dispatch_program_chains { } }; } + +// Get all registered dispatcher names from the program +pub 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() +} |
