From 2dff21cc78fd2d6a4fa4f227f6ad94e3f7baa943 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Tue, 28 Jul 2026 19:11:14 +0800 Subject: feat(mingling_macros, mingling_pathf): add `#[command]` attribute macro Add a new `#[command]` attribute macro (feature-gated behind `extra_macros`) that converts a plain function with a `Vec` parameter into a fully wired Mingling command. The macro generates a `dispatcher!` call, a `#[chain]` wrapper, and a hidden module re-exporting all generated types. Also add `CommandPattern` to the pathf pattern analyzer to recognize `#[command]`-annotated functions and track their generated hidden modules. --- mingling/src/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'mingling/src/lib.rs') diff --git a/mingling/src/lib.rs b/mingling/src/lib.rs index 19f2188..d7c8e8f 100644 --- a/mingling/src/lib.rs +++ b/mingling/src/lib.rs @@ -52,6 +52,9 @@ pub mod macros { pub use mingling_macros::buffer; /// `#[chain]` - Used to generate a struct implementing the `Chain` trait via a method pub use mingling_macros::chain; + /// `#[command]` - Declares a command from a plain function with `Vec` entry + #[cfg(feature = "extra_macros")] + pub use mingling_macros::command; /// `#[completion(EntryType)]` - Used to generate completion entry #[cfg(feature = "comp")] pub use mingling_macros::completion; @@ -223,6 +226,9 @@ pub mod prelude { /// Re-export of the `chain` macro for defining a chain of commands. #[cfg(feature = "macros")] pub use crate::macros::chain; + /// Re-export of the `#[command]` macro for declaring commands from plain functions. + #[cfg(all(feature = "extra_macros", feature = "macros"))] + pub use crate::macros::command; /// Re-export of the `dispatcher` macro for routing commands. #[cfg(feature = "macros")] pub use crate::macros::dispatcher; -- cgit