aboutsummaryrefslogtreecommitdiff
path: root/mingling_macros/src/lib.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-05-24 17:06:54 +0800
committer魏曹先生 <1992414357@qq.com>2026-05-24 17:06:54 +0800
commit60e70f5320b2abdb38a2349c18e5bffcfea37ca7 (patch)
tree3402af0a2822255c1c3f9c77affe6da81c9d1279 /mingling_macros/src/lib.rs
parent11adad7db1b6202d5366527902c3f0a9fb90654f (diff)
Add implicit dispatcher macro with auto-derived names
Diffstat (limited to 'mingling_macros/src/lib.rs')
-rw-r--r--mingling_macros/src/lib.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/mingling_macros/src/lib.rs b/mingling_macros/src/lib.rs
index 57f37a1..73f2fa5 100644
--- a/mingling_macros/src/lib.rs
+++ b/mingling_macros/src/lib.rs
@@ -297,6 +297,25 @@ pub fn empty_result(_input: TokenStream) -> TokenStream {
/// dispatcher!(MyProgram, "command.path", CommandStruct => EntryStruct);
/// ```
///
+/// ## Abbreviated syntax (requires `extra_macros` feature)
+///
+/// When the `extra_macros` feature is enabled, the `CommandStruct => EntryStruct`
+/// portion can be omitted. The struct names are auto-derived from the command path
+/// using PascalCase conversion:
+///
+/// ```rust,ignore
+/// // Auto-derives: "remote.add" → CMDRemoteAdd ⇒ EntryRemoteAdd
+/// dispatcher!("remote.add");
+///
+/// // Auto-derives: "cmd.sub.leaf" → CMDCmdSubLeaf ⇒ EntryCmdSubLeaf
+/// dispatcher!("cmd.sub.leaf");
+/// ```
+///
+/// The generated code is equivalent to writing:
+/// ```rust,ignore
+/// dispatcher!("remote.add", CMDRemoteAdd => EntryRemoteAdd);
+/// ```
+///
/// # Example
///
/// ```rust,ignore
@@ -310,6 +329,9 @@ pub fn empty_result(_input: TokenStream) -> TokenStream {
///
/// // With explicit program:
/// dispatcher!(MyApp, "status", StatusCommand => StatusEntry);
+///
+/// // Abbreviated form (requires extra_macros):
+/// // dispatcher!("remote.add");
/// ```
///
/// The generated `HelloCommand` implements `Dispatcher<ThisProgram>`: