diff options
Diffstat (limited to 'examples/example-command-macro')
| -rw-r--r-- | examples/example-command-macro/Cargo.lock | 6 | ||||
| -rw-r--r-- | examples/example-command-macro/src/main.rs | 30 |
2 files changed, 16 insertions, 20 deletions
diff --git a/examples/example-command-macro/Cargo.lock b/examples/example-command-macro/Cargo.lock index cd1babf..53d6f18 100644 --- a/examples/example-command-macro/Cargo.lock +++ b/examples/example-command-macro/Cargo.lock @@ -74,7 +74,7 @@ dependencies = [ [[package]] name = "mingling" -version = "0.4.0" +version = "0.5.0" dependencies = [ "arg-picker", "mingling_core", @@ -83,7 +83,7 @@ dependencies = [ [[package]] name = "mingling_core" -version = "0.4.0" +version = "0.5.0" dependencies = [ "just_fmt", "might_be_async", @@ -91,7 +91,7 @@ dependencies = [ [[package]] name = "mingling_macros" -version = "0.4.0" +version = "0.5.0" dependencies = [ "just_fmt", "proc-macro2", diff --git a/examples/example-command-macro/src/main.rs b/examples/example-command-macro/src/main.rs index 2bf932a..6740518 100644 --- a/examples/example-command-macro/src/main.rs +++ b/examples/example-command-macro/src/main.rs @@ -19,37 +19,33 @@ use mingling::{macros::buffer, picker::IntoPicker, prelude::*}; fn main() { - let mut program = ThisProgram::new(); - - // Import the dispatchers generated by the `#[command]` macro - program.with_dispatcher(CMDHelloWorld); - program.with_dispatcher(CMDGreetSomeone); - program.with_dispatcher(CMDGoodBye); - - program.exec_and_exit(); + ThisProgram::new().exec_and_exit(); } -pack!(ResultGreeting = String); -pack!(ResultGoodbye = ()); +#[derive(Grouped, Wrap)] +pub struct ResultGreeting(String); + +#[derive(Grouped)] +pub struct ResultGoodbye; // --------- IMPORTANT --------- -// Auto-generates dispatcher!("hello.world", CMDHelloWorld => EntryHelloWorld); +// Auto-generates dispatcher!("hello.world", EntryHelloWorld); #[command] fn hello_world() -> ResultGreeting { - ResultGreeting::new("World".to_string()) + ResultGreeting("World".to_string()) } -// Auto-generates dispatcher!("hello-world", CMDGreetSomeone => EntryGreetSomeone); +// Auto-generates dispatcher!("hello-world", EntryGreetSomeone); #[command(node = "greet-someone")] fn greet_someone(args: Vec<String>) -> ResultGreeting { let name = args.pick_or(&arg![String], || "World".to_string()).unwrap(); - ResultGreeting::new(name) + ResultGreeting(name) } -// Auto-generates dispatcher!("goodbye", CMDGoodBye => EntryGoodBye); -#[command(name = CMDGoodBye, entry = EntryGoodBye)] +// Auto-generates dispatcher!("goodbye", EntryGoodBye); +#[command(entry = EntryGoodBye)] fn goodbye() -> ResultGoodbye { - ResultGoodbye::default() + ResultGoodbye } // --------- IMPORTANT --------- |
