aboutsummaryrefslogtreecommitdiff
path: root/examples/example-setup/src
diff options
context:
space:
mode:
authorWeicao-CatilGrass <1992414357@qq.com>2026-05-23 23:41:04 +0800
committerWeicao-CatilGrass <1992414357@qq.com>2026-05-23 23:49:34 +0800
commit0a2ef958c0dca21d19e4ffc38ba5a7c4078e182a (patch)
treec82fc4242ed393b132ba514eb434d722e7d9c387 /examples/example-setup/src
parentccab1940c019dfbfb7dfcbbe4cb927258933755f (diff)
Rework examples and add entry macro for testing
Diffstat (limited to 'examples/example-setup/src')
-rw-r--r--examples/example-setup/src/main.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/examples/example-setup/src/main.rs b/examples/example-setup/src/main.rs
new file mode 100644
index 0000000..c445276
--- /dev/null
+++ b/examples/example-setup/src/main.rs
@@ -0,0 +1,33 @@
+//! Example Setup
+//!
+//! > This example demonstrates how to build a custom Setup for modular management of project components
+
+use mingling::{Program, macros::program_setup, prelude::*};
+
+fn main() {
+ let mut program = ThisProgram::new();
+
+ // --------- IMPORTANT ---------
+ // Introduce `CustomSetup` generated by `custom_setup`
+ program.with_setup(CustomSetup);
+ // --------- IMPORTANT ---------
+
+ program.exec_and_exit();
+}
+
+// --------- IMPORTANT ---------
+// Define `CustomSetup` (inferred from `custom_setup`)
+// Package part of the program construction logic into this type for modular management
+#[program_setup]
+fn custom_setup(program: &mut Program<ThisProgram>) {
+ program.with_dispatchers((CMD1, CMD2, CMD3, CMD4, CMD5));
+}
+// --------- IMPORTANT ---------
+
+dispatcher!("1", CMD1 => Entry1);
+dispatcher!("2", CMD2 => Entry2);
+dispatcher!("3", CMD3 => Entry3);
+dispatcher!("4", CMD4 => Entry4);
+dispatcher!("5", CMD5 => Entry5);
+
+gen_program!();