From e875a80d52e5e44f107366cd4825936c44c824bb Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Fri, 8 May 2026 15:48:54 +0800 Subject: Add dispatch tree example and update doc version references --- mingling/src/example_docs.rs | 65 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) (limited to 'mingling/src/example_docs.rs') diff --git a/mingling/src/example_docs.rs b/mingling/src/example_docs.rs index c23db8d..aca27ce 100644 --- a/mingling/src/example_docs.rs +++ b/mingling/src/example_docs.rs @@ -133,7 +133,7 @@ pub mod example_async {} /// # How to Deploy /// 1. Enable the `comp` feature /// ```toml -/// mingling = { version = "0.1.5", features = [ +/// mingling = { version = "...", features = [ /// "comp", // Enable this feature /// "parser" /// ] } @@ -447,3 +447,66 @@ pub mod example_general_renderer {} /// gen_program!(); /// ``` pub mod example_picker {} +/// `Mingling` Example - Dispatch Tree +/// +/// # How to Deploy +/// 1. Enable the `dispatch_tree` feature (`comp` is optional) +/// ```toml +/// mingling = { version = "...", features = [ +/// "dispatch_tree", // Enable this feature +/// "comp" // optional +/// ] } +/// ``` +/// +/// 2. Using `cargo expand`: +/// +/// ```bash +/// cargo expand --manifest-path examples/example-dispatch-tree/Cargo.toml > expanded.rs +/// cat expanded.rs | grep dispatch_args_trie -A 264 +/// ``` +/// +/// Cargo.toml +/// ```ignore +/// [package] +/// name = "example-dispatch-tree" +/// version = "0.1.0" +/// edition = "2024" +/// +/// [dependencies] +/// mingling = { path = "../../mingling", features = ["dispatch_tree", "comp"] } +/// ``` +/// +/// main.rs +/// ```ignore +/// #![allow(unused_mut)] +/// +/// use mingling::macros::{dispatcher, gen_program}; +/// +/// fn main() { +/// let mut program = ThisProgram::new(); +/// +/// // After enabling `dispatch_tree`, this method will no longer exist +/// // program.with_dispatcher(CommandGreet); +/// // +/// // The `CompletionDispatcher` automatically generated by `comp` will also be imported +/// // automatically +/// // program.with_dispatcher(CompletionDispatcher); +/// +/// program.exec(); +/// } +/// +/// dispatcher!("greet", CommandGreet => EntryGreet); +/// dispatcher!("help", CommandHelp => EntryHelp); +/// dispatcher!("quit", CommandQuit => EntryQuit); +/// dispatcher!("list", CommandList => EntryList); +/// dispatcher!("status", CommandStatus => EntryStatus); +/// dispatcher!("save", CommandSave => EntrySave); +/// dispatcher!("load", CommandLoad => EntryLoad); +/// dispatcher!("config", CommandConfig => EntryConfig); +/// dispatcher!("run", CommandRun => EntryRun); +/// dispatcher!("debug", CommandDebug => EntryDebug); +/// dispatcher!("version", CommandVersion => EntryVersion); +/// +/// gen_program!(); +/// ``` +pub mod example_dispatch_tree {} -- cgit