aboutsummaryrefslogtreecommitdiff
path: root/mingling/src/example_docs.rs
blob: 7e87d9ca7d988d76d067623e1c7542dee190e878 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
// Auto generated

/// Example Argument Parse
///
///  > This example demonstrates how to use the `parser` feature to parse user input
///
///  Run:
///  ```bash
///  cargo run --manifest-path examples/example-argument-parse/Cargo.toml --quiet -- transfer README.md --size 32kib
///  cargo run --manifest-path examples/example-argument-parse/Cargo.toml --quiet -- transfer src/ --dir
///  cargo run --manifest-path examples/example-argument-parse/Cargo.toml --quiet -- strict-transfer README.md
///  cargo run --manifest-path examples/example-argument-parse/Cargo.toml --quiet -- strict-transfer --dir
///  ```
///
///  Output:
///  ```plaintext
///  file: README.md (32768)
///  dir: src/ (1048576)
///  file: README.md (1048576)
///  Error: name is not provided
///  ```
///
/// Source code (./Cargo.toml)
/// ```toml
/// [package]
/// name = "example-argument-parse"
/// version = "0.1.0"
/// edition = "2024"
///
/// [dependencies.mingling]
/// path = "../../mingling"
///
/// # Enable `parser` features
/// features = ["parser", "extra_macros"]
/// ```
///
/// Source code (./src/main.rs)
/// ```ignore
/// use mingling::{macros::route, prelude::*};
///
/// dispatcher!("transfer", CMDTransfer => EntryTransfer);
/// dispatcher!("strict-transfer", CMDStrictTransfer => EntryStrictTransfer);
///
/// pack!(ResultFile = (bool, usize, String)); // (IsDir, Size, Name)
///
/// #[chain]
/// fn handle_transfer_parse(args: EntryTransfer) -> Next {
///     // --------- IMPORTANT ---------
///     // First parse flag arguments (like --dir/-D), then positional arguments
///     let result: ResultFile = args
///         // Name --dir --size 20mib
///         //            ^^^^^^^^^^^^_ first
///         .pick::<bool>(["--dir", "-D"])
///         // Name --dir
///         //      ^^^^^_ second (or `-D`)
///         .pick_or::<usize>("--size", 1024 * 1024_usize)
///         // Name
///         // ^^^^_ finally, pick positional arg
///         .pick::<String>(())
///         .after(|str| str.trim().replace(' ', ""))
///         // Unpack to tuple (is_dir, size, name)
///         .unpack()
///         // Convert into ResultFile
///         .into();
///     // --------- IMPORTANT ---------
///     result
/// }
///
/// pack!(ErrorNoNameProvided = ());
///
/// #[chain]
/// fn handle_strict_transfer_parse(args: EntryStrictTransfer) -> Next {
///     // --------- IMPORTANT ---------
///     // Strict parsing: error immediately if the name is not provided
///     let result: ResultFile = route! { // Use `route!` to wrap a Picker that contains `or_route`
///         args
///             .pick::<bool>(["--dir", "-D"])
///             .pick_or::<usize>("--size", 1024 * 1024_usize)
///             // Finally parse the positional argument; if not found, route to `ErrorNoNameProvided`
///             .pick_or_route::<String, _>((), ErrorNoNameProvided::default().to_chain())
///             .after(|str| str.trim().replace(' ', ""))
///             .unpack()
///     }
///     // Convert into ResultFile
///     .into();
///     // --------- IMPORTANT ---------
///     result.to_chain()
/// }
///
/// /// Renders the parsed transfer result (file/dir, size, name).
/// #[renderer]
/// fn render_result_file(result: ResultFile) {
///     let (is_dir, size, name) = result.into();
///     r_println!(
///         "{}: {} ({})",
///         if is_dir { "dir" } else { "file" },
///         name,
///         size
///     )
/// }
///
/// /// Renders the error when no name is provided.
/// #[renderer]
/// fn render_error_no_name_provided(_: ErrorNoNameProvided) {
///     r_println!("Error: name is not provided")
/// }
///
/// gen_program!();
///
/// fn main() {
///     let mut program = ThisProgram::new();
///     program.with_dispatcher(CMDTransfer);
///     program.with_dispatcher(CMDStrictTransfer);
///     program.exec_and_exit();
/// }
/// ```
pub mod example_argument_parse {}
/// Example Async Runtime Support
///
///  > This example shows how to drive an async runtime using the `async` feature
///
///  ## Note
///
///  When the `async` feature is enabled, **Mingling** provides a different framework implementation,
///  allowing you to use the `async` keyword directly within `#[chain]`.
///
///  However, you will lose some capabilities:
///
///  1. `&mut` resource injection is not available in async chain functions
///  2. The program will not be able to use panic unwind functionality
///
///  Run:
///  ```bash
///  cargo run --manifest-path examples/example-async-support/Cargo.toml --quiet -- download README.md
///  ```
///
///  Output:
///  ```plaintext
///  Download begin
///  # (Will pause for 1 second here)
///  "README.md" downloaded.
///  ```
///
/// Source code (./Cargo.toml)
/// ```toml
/// [package]
/// name = "example-async-support"
/// version = "0.1.0"
/// edition = "2024"
///
/// [dependencies.mingling]
/// path = "../../mingling"
///
/// # Enable `parser` features
/// features = ["async", "parser"]
///
/// # Import any async runtime, e.g. Tokio
/// [dependencies.tokio]
/// version = "1.52.3"
/// features = ["macros", "rt", "rt-multi-thread", "time"]
/// ```
///
/// Source code (./src/main.rs)
/// ```ignore
/// use mingling::{hook::ProgramHook, prelude::*};
///
/// #[tokio::main]
/// async fn main() {
///     let mut program = ThisProgram::new();
///
///     program.with_dispatcher(CMDDownload);
///
///     // Add a hook to display when the download begins
///     program.with_hook(ProgramHook::empty().on_begin(|| println!("Download begin")));
///
///     // --------- IMPORTANT ---------
///     // The return values of `exec_*()` related functions have been replaced with Futures
///     program.exec_and_exit().await;
///     // --------- IMPORTANT ---------
/// }
///
/// dispatcher!("download", CMDDownload => EntryDownload);
///
/// pack!(ResultDownloaded = String);
///
/// // --------- IMPORTANT ---------
/// #[chain]
/// //  vvvvv_ `async` keyword can be used directly here
/// pub async fn handle_download(args: EntryDownload) -> Next {
///     let file_name = args.pick(()).unpack();
///     fake_download(file_name).await
/// }
///
/// /// Renders the downloaded file name.
/// #[renderer]
/// // But renderers cannot use the `async` keyword
/// pub fn render_downloaded(result: ResultDownloaded) {
///     r_println!("\"{}\" downloaded.", *result);
/// }
/// // --------- IMPORTANT ---------
///
/// gen_program!();
///
/// async fn fake_download(file_name: String) -> ResultDownloaded {
///     tokio::time::sleep(std::time::Duration::from_secs(1)).await;
///     ResultDownloaded::new(file_name)
/// }
/// ```
pub mod example_async_support {}
/// Example The Basic Usage of Mingling
///
///  Run:
///  ```base
///  cargo run --manifest-path examples/example-basic/Cargo.toml --quiet -- greet
///  cargo run --manifest-path examples/example-basic/Cargo.toml --quiet -- greet Alice
///  ```
///
///  Output:
///  ```plaintext
///  Hello, World!
///  Hello, Alice!
///  ```
///
/// Source code (./Cargo.toml)
/// ```toml
/// [package]
/// name = "example-basic"
/// version = "0.1.0"
/// edition = "2024"
///
/// [dependencies]
/// mingling = { path = "../../mingling" }
/// ```
///
/// Source code (./src/main.rs)
/// ```ignore
/// // Import commonly used Mingling modules
/// use mingling::prelude::*;
///
/// // Define the `greet` subcommand
/// //            _____________________________ subcmd name, can be nested (e.g. "remote.add" "remote.rm")
/// //           /        _____________________ dispatcher name
/// //           |       /            _________ entry, records raw arguments
/// //           |       |           /                         ^^^^^^^^^^^^^
/// //           vvvvv   vvvvvvvv    vvvvvvvvvv                \_ equivalent to pack!(EntryGreet = Vec<String>)
/// dispatcher!("greet", CMDGreet => EntryGreet);
///
/// fn main() {
///     // Create a new ThisProgram
///     let mut program = ThisProgram::new();
///
///     // Add the CMDGreet dispatcher
///     program.with_dispatcher(CMDGreet);
///
///     // Run the program, then exit the process
///     program.exec_and_exit();
/// }
///
/// // Quickly wrap a type into a type recognizable by the current program
/// //     ____________________ Wrapped type name
/// //    /             _______ Wrapped type inner value
/// //    |            /
/// //    vvvvvvvvvv   vvvvvv
/// pack!(ResultName = String);
///
/// // Define the `handle_greet` chain for parsing input text
/// //                     ____________________ Previous type:
/// //                    /                       Mingling deduces types at runtime and routes them to this function
/// //                    |               _____ will be expanded to:
/// //                    |              /        impl Into<mingling::ChainProcess<ThisProgram>>
/// #[chain] //           vvvvvvvvvv     vvvv
/// fn handle_greet(args: EntryGreet) -> Next {
///     let name: ResultName = args
///         .inner
///         .first()
///         .cloned()
///         .unwrap_or_else(|| "World".to_string())
///         .into();
///     name
/// }
///
/// // Define renderer `render_name`, used to render `ResultName`
/// /// Renders the greeting message with the provided name.
/// #[renderer]
/// fn render_name(name: ResultName) {
///     r_println!("Hello, {}!", *name);
/// }
///
/// // Note: This macro generates the program entry point.
/// // It must be placed at the end of the root module of the crate (>= mingling@0.1.8).
/// //                          ^^^^^^     ^^^^^^^^^^^
/// // For example: lib.rs, main.rs
/// gen_program!();
/// ```
pub mod example_basic {}
/// Example Clap Binding
///
///  > This example demonstrates how to bind clap_derive to Mingling
///
///  **Note**:
///  If the `error` parameter of the `dispatcher_clap!` macro is enabled, arguments will be parsed using `try_parse_from`.
///  If you need such output to support ANSI colors, enable the `color` feature of `clap`.
///
///  Run:
///  ```bash
///  cargo run --manifest-path examples/example-clap-binding/Cargo.toml --quiet -- greet
///  cargo run --manifest-path examples/example-clap-binding/Cargo.toml --quiet -- greet Alice
///  cargo run --manifest-path examples/example-clap-binding/Cargo.toml --quiet -- greet Alice -r 5
///  cargo run --manifest-path examples/example-clap-binding/Cargo.toml --quiet -- greet --help
///  cargo run --manifest-path examples/example-clap-binding/Cargo.toml --quiet -- greet --rppat
///  ```
///
///  Output:
///  ```plaintext
///  Hello, World!
///  Hello, Alice!
///  Hello, Alice, Alice, Alice, Alice, Alice!
///  Usage: example-clap-binding [OPTIONS] [NAME]
///
///  Arguments:
///    [NAME]  [default: World]
///
///  Options:
///    -r, --repeat <REPEAT>  [default: 1]
///    -h, --help             Print help
///
///  error: unexpected argument '--rppat' found
///
///    tip: a similar argument exists: '--repeat'
///
///  Usage: example-clap-binding --repeat <REPEAT> [NAME]
///
///  For more information, try '--help'.
///  ```
///
/// Source code (./Cargo.toml)
/// ```toml
/// [package]
/// name = "example-clap-binding"
/// version = "0.1.0"
/// edition = "2024"
///
/// [dependencies.mingling]
/// path = "../../mingling"
/// # Enable `clap` features
/// features = ["clap"]
///
/// # Import `clap` to your project
/// [dependencies.clap]
/// version = "4.6.1"
/// features = [
///     # Enable `derive` feature to support `clap::Parser`
///     "derive",
///     # Enable `color` feature to support ANSI colors
///     "color",
/// ]
/// ```
///
/// Source code (./src/main.rs)
/// ```ignore
/// use mingling::{macros::dispatcher_clap, prelude::*, setup::BasicProgramSetup, Groupped};
///
/// fn main() {
///     let mut program = ThisProgram::new();
///
///     // --------- IMPORTANT ---------
///     // Introduce BasicProgramSetup to support ["--help", "-h"] options
///     program.with_setup(BasicProgramSetup);
///
///     // Set clap help output mode
///     program.stdout_setting.clap_help_print_behaviour =
///         mingling::ClapHelpPrintBehaviour::WriteToRenderResult;
///     //  mingling::ClapHelpPrintBehaviour::PrintDirectly
///     //
///     // PrintDirectly:
///     //   Let Clap print help information directly to stdout
///     //
///     // WriteToRenderResult:
///     //   Capture Clap's help information and write to RenderResult
///     // --------- IMPORTANT ---------
///
///     program.with_dispatcher(CMDGreet);
///     program.exec_and_exit();
/// }
///
/// // Implement Clap Parser, and bind to Dispatcher
/// //        _______________________________ Default trait, provides fallback on parse failure
/// //       /         ______________________ clap::Parser, parsing logic implemented by Clap
/// //       |        /              ________ Implement mingling::Groupped
/// //       |        |             /           to ensure Mingling can recognize the type
/// //       vvvvvvv  vvvvvvvvvvvv  vvvvvvvv
/// #[derive(Default, clap::Parser, Groupped)]
/// #[dispatcher_clap(
///     "greet", CMDGreet,        // Bind EntryGreet to "greet" command
///     help = true,              // Generate clap help for EntryGreet
///     error = ErrorGreetParsed, // Generate and bind error type for parse failure
/// //  ^^^^^\__ Using `error` intercepts parse failure information into the specified type,
/// //              which is then rendered by the renderer
/// )]
/// pub struct EntryGreet {
///     // Positional argument
///     #[clap(default_value = "World")]
///     name: String,
///
///     // Option argument
///     #[arg(short, long, default_value_t = 1)]
///     repeat: i32,
/// }
///
/// /// Renders the greet output with optional repetition.
/// #[renderer]
/// fn render_greet(greet: EntryGreet) {
///     let name = greet.name;
///     let count = greet.repeat.max(0) as usize;
///
///     r_print!("Hello, ");
///     for i in 0..count {
///         r_print!("{name}");
///         if i < count - 1 {
///             r_print!(", ");
///         }
///     }
///     r_println!("!");
/// }
///
/// /// Renders the error message when greet argument parsing fails.
/// #[renderer]
/// fn render_greet_parse_failed(err: ErrorGreetParsed) {
///     r_println!("{}", *err);
/// }
///
/// gen_program!();
/// ```
pub mod example_clap_binding {}
/// Example Completion
///
///  > This example demonstrates how to use **Mingling** to create fully dynamic command-line completions
///
///  ## About Completion Scripts
///
///  To make your completions work, you need to generate a completion script using Mingling's tools
///
///  1. Enable features
///     You need to enable the `builds` and `comp` features for `mingling` in `[build-dependencies]`
///
///  2. Write `build.rs`
///     Write the following in `build.rs`
///
///  ```rust,ignore
///  fn main() {
///      build_scripts();
///  }
///
///  /// Generate completion scripts
///  fn build_scripts() {
///      // `env!("CARGO_PKG_NAME")` equals the crate name, which matches the binary name.
///      // If your binary name differs from the crate name, specify it explicitly.
///      mingling::build::build_comp_scripts(
///          // Your binary name:
///          env!("CARGO_PKG_NAME"),
///      )
///      .unwrap();
///  }
///  ```
///
///  3. Verify
///     Build your project with `cargo build --release`. The completion scripts will be generated in `target/release/`
///
///     Execute the script or have it be automatically sourced by your Shell
///
///  Run:
///  ```bash
///  cargo run --manifest-path examples/example-completion/Cargo.toml --quiet -- greet Alice --repeat 3
///  ```
///
///  Output:
///  ```plaintext
///  Hello, Alice, Alice, Alice!
///  ```
///
/// Source code (./Cargo.toml)
/// ```toml
/// [package]
/// name = "example-completion"
/// version = "0.1.0"
/// edition = "2024"
///
/// [dependencies.mingling]
/// path = "../../mingling"
///
/// features = [
///     # Enable `comp` features
///     "comp",
///     "parser",
/// ]
///
/// [build-dependencies.mingling]
/// path = "../../mingling"
///
/// features = [
///     # Enable `comp` features
///     "comp",
///
///     # If you want to build completion scripts,
///     # enable `builds` features
///     "builds",
/// ]
/// ```
///
/// Source code (./src/main.rs)
/// ```ignore
/// use mingling::{macros::suggest, prelude::*, ShellContext, Suggest};
///
/// fn main() {
///     let mut program = ThisProgram::new();
///
///     program.with_dispatcher(CMDGreet);
///
///     // --------- IMPORTANT ---------
///     // The `comp` feature makes `gen_program!()` generate a CMDCompletion automatically
///     // It adds a hidden `__comp` subcommand for communication with the completion script
///     program.with_dispatcher(crate::CMDCompletion);
///     // --------- IMPORTANT ---------
///
///     // TIP: Note that the completion script reads stdout,
///     // so make sure no output is produced before the CMDCompletion is dispatched.
///     program.exec_and_exit();
/// }
///
/// // --------- IMPORTANT ---------
/// //            __________________________________________ Entry point bound to completion behavior
/// //           /                 _________________________ Shell context for obtaining user input state
/// //           |                /                 ________ Suggest, used to return completion results
/// //           vvvvvvvvvv       |                /
/// #[completion(EntryGreet)] //  vvvvvvvvvvvv     vvvvvvv
/// fn complete_greet_entry(ctx: &ShellContext) -> Suggest {
///     // When the previous word is `greet` (the current command being typed)
///     if ctx.previous_word == "greet" {
///         // Return suggestions
///         return suggest! {
///             "Bob": "Likes to pass messages",
///             "Alice": "Likes to receive messages",
///             "Hacker": "YOU",
///             "World"
///         };
///     }
///
///     // When the user is typing `--repeat`
///     if ctx.filling_argument(["-r", "--repeat"]) {
///         return suggest! {}; // Don't suggest anything
///     }
///
///     // When the user is typing `-`
///     if ctx.typing_argument() {
///         return suggest! {
///             "-r": "Number of repetitions",
///             "--repeat": "Number of repetitions",
///         }
///         // Remove arguments that have already been typed by the user
///         .strip_typed_argument(ctx);
///     }
///
///     // Otherwise, suggest nothing
///     suggest!()
///     // // You can also enable file completions using the following code,
///     // // which will invoke the Shell's default behavior
///     // Suggest::file_comp()
/// }
/// // --------- IMPORTANT ---------
///
/// dispatcher!("greet", CMDGreet => EntryGreet);
/// pack!(ResultName = (u8, String));
///
/// #[chain]
/// fn handle_greet(args: EntryGreet) -> Next {
///     let result: ResultName = args
///         .pick_or(["-r", "--repeat"], 1)
///         .pick_or((), "World")
///         .unpack()
///         .into();
///     result
/// }
///
/// /// Renders the greeting with the result name and repeat count.
/// #[renderer]
/// fn render_name(result: ResultName) {
///     let (repeat, name) = result.inner;
///     let mut parts = Vec::with_capacity(repeat as usize);
///     for _ in 0..repeat {
///         parts.push(name.clone());
///     }
///     r_println!("Hello, {}!", parts.join(", "));
/// }
///
/// gen_program!();
/// ```
pub mod example_completion {}
/// Example Custom Pickable
///
///  > This example demonstrates how to use the Pickable trait to add parsing for your types
///
///  Run:
///  ```bash
///  cargo run --manifest-path examples/example-custom-pickable/Cargo.toml --quiet -- connect 127.0.0.1:5012
///  cargo run --manifest-path examples/example-custom-pickable/Cargo.toml --quiet -- connect 127.0.0.1
///  ```
///
///  Output:
///  ```plaintext
///  Connected to "127.0.0.1:5012"
///  Failed to parse address
///  ```
///
/// Source code (./Cargo.toml)
/// ```toml
/// [package]
/// name = "example-custom-pickable"
/// version = "0.1.0"
/// edition = "2024"
///
/// [dependencies.mingling]
/// path = "../../mingling"
///
/// features = ["parser", "extra_macros"]
/// ```
///
/// Source code (./src/main.rs)
/// ```ignore
/// use mingling::{macros::route, parser::Pickable, prelude::*, Groupped};
///
/// // Define types that can be recognized by Mingling
/// //               ________________________ `Pickable` trait needs to implement Default
/// //              /                ________ The Groupped derive macro registers an ID for this type
/// //              |               /           Mingling uses this ID to identify the type
/// //              vvvvvvv         vvvvvvvv
/// #[derive(Debug, Default, Clone, Groupped)]
/// pub struct Address {
///     pub ip: [u8; 4],
///     pub port: u16,
/// }
///
/// // --------- IMPORTANT ---------
/// impl Pickable for Address {
///     type Output = Address;
///     fn pick(args: &mut mingling::parser::Argument, flag: mingling::Flag) -> Option<Self::Output> {
///         // Extract the raw string from Argument using the Flag
///         let raw: String = args.pick_argument(flag)?.clone();
///
///         // Use TryFrom to parse the address
///         Address::try_from(raw).ok()
///     }
/// }
/// // --------- IMPORTANT ---------
///
/// dispatcher!("connect", CMDConnect => EntryConnect);
/// pack!(ErrorParseAddressFailed = ());
///
/// #[chain]
/// fn handle_connect(prev: EntryConnect) -> Next {
///     let connect: Address =
///         route! { prev.pick_or_route((), ErrorParseAddressFailed::default().to_chain()).unpack() };
///     connect.to_chain()
/// }
///
/// /// Renders the connected address.
/// #[renderer]
/// fn render_address(addr: Address) {
///     r_println!("Connected to \"{}\"", addr.to_string());
/// }
///
/// /// Renders the error message when address parsing fails.
/// #[renderer]
/// fn render_error_parse_address_failed(_: ErrorParseAddressFailed) {
///     r_println!("Failed to parse address");
/// }
///
/// gen_program!();
///
/// fn main() {
///     let mut program = ThisProgram::new();
///     program.with_dispatcher(CMDConnect);
///     program.exec_and_exit();
/// }
///
/// // Address conversion
///
/// impl TryFrom<String> for Address {
///     type Error = String;
///
///     fn try_from(raw: String) -> Result<Self, Self::Error> {
///         // Expected format: "192.168.1.1:8080"
///         let parts: Vec<&str> = raw.split(':').collect();
///         if parts.len() != 2 {
///             return Err("Invalid format: expected 'IP:PORT'".to_string());
///         }
///
///         let ip_str = parts[0];
///         let port_str = parts[1];
///
///         // Parse IP address (4 octets separated by dots)
///         let ip_parts: Vec<&str> = ip_str.split('.').collect();
///         if ip_parts.len() != 4 {
///             return Err("Invalid IP address format".to_string());
///         }
///
///         let mut ip = [0u8; 4];
///         for (i, part) in ip_parts.iter().enumerate() {
///             ip[i] = part
///                 .parse::<u8>()
///                 .map_err(|_| format!("Invalid IP octet: {part}"))?;
///         }
///
///         // Parse port
///         let port = port_str
///             .parse::<u16>()
///             .map_err(|_| format!("Invalid port: {port_str}"))?;
///
///         Ok(Address { ip, port })
///     }
/// }
///
/// impl From<Address> for String {
///     fn from(addr: Address) -> String {
///         format!(
///             "{}.{}.{}.{}:{}",
///             addr.ip[0], addr.ip[1], addr.ip[2], addr.ip[3], addr.port
///         )
///     }
/// }
///
/// impl std::fmt::Display for Address {
///     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
///         write!(
///             f,
///             "{}.{}.{}.{}:{}",
///             self.ip[0], self.ip[1], self.ip[2], self.ip[3], self.port
///         )
///     }
/// }
/// ```
pub mod example_custom_pickable {}
/// Example Dispatch Tree
///
///  > This example will introduce how to use `dispatch_tree`
///  > to optimize your command line lookup efficiency
///
///  When the number of commands in your project increases, you can use `dispatch_tree` to complete command registration at compile time.
///  It will generate a trie for quickly finding related commands by prefix.
///
///  Therefore, after enabling this feature,
///  `Program` will no longer store a Dispatcher list internally, and the `with_dispatcher` function will not be compiled.
///
///  Run:
///  ```bash
///  cargo run --manifest-path examples/example-dispatch-tree/Cargo.toml --quiet -- cmd5
///  ```
///
///  Output:
///  ```plaintext
///  It's works!
///  ```
///
/// Source code (./Cargo.toml)
/// ```toml
/// [package]
/// name = "example-dispatch-tree"
/// version = "0.1.0"
/// edition = "2024"
///
/// [dependencies.mingling]
/// path = "../../mingling"
///
/// features = [
///     "dispatch_tree",
/// ]
/// ```
///
/// Source code (./src/main.rs)
/// ```ignore
/// use mingling::prelude::*;
///
/// // --------- IMPORTANT ---------
/// // You have a large number of subcommands
/// dispatcher!("cmd1",         CMD1 => Entry1);
/// dispatcher!("cmd2.sub1",   CMD2Sub1 => Entry2Sub1);
/// dispatcher!("cmd2.sub2",   CMD2Sub2 => Entry2Sub2);
/// dispatcher!("cmd3.sub1.leaf1", CMD3Sub1Leaf1 => Entry3Sub1Leaf1);
/// dispatcher!("cmd3.sub1.leaf2", CMD3Sub1Leaf2 => Entry3Sub1Leaf2);
/// dispatcher!("cmd3.sub2",   CMD3Sub2 => Entry3Sub2);
/// dispatcher!("cmd4.sub1.subsub1.deep", CMD4Deep => Entry4Deep);
/// dispatcher!("cmd4.sub1.subsub2",      CMD4SubSub2 => Entry4SubSub2);
/// dispatcher!("cmd5",        CMD5 => Entry5);
/// dispatcher!("cmd5.extra",  CMD5Extra => Entry5Extra);
/// dispatcher!("nested.a.b.c", CMDA => EntryA);
/// dispatcher!("nested.a.b.d", CMDB => EntryB);
/// dispatcher!("nested.a.e",   CMDC => EntryC);
/// dispatcher!("nested.f",     CMDD => EntryD);
/// // --------- IMPORTANT ---------
///
/// fn main() {
///     let program = ThisProgram::new();
///
///     // --------- IMPORTANT ---------
///     // // You no longer need to use `with_dispatcher` anymore;
///     // // it'll be collected automatically once the `dispatch_tree` feature is enabled
///     // program.with_dispatcher(...);
///
///     program.exec_and_exit();
/// }
///
/// /// Renders the confirmation message for the `cmd5` command.
/// #[renderer]
/// fn render_cmd5(_: Entry5) {
///     r_println!("It's works!");
/// }
///
/// gen_program!();
/// ```
pub mod example_dispatch_tree {}
/// Example Enum Tag
///
///  > This example demonstrates how to use the `EnumTag` derive macro to tag enum variants with metadata,
///  > which can be used for autocompletion and parsing
///
///  Run:
///  ```bash
///  cargo run --manifest-path examples/example-enum-tag/Cargo.toml --quiet -- lang-select OCaml
///  cargo run --manifest-path examples/example-enum-tag/Cargo.toml --quiet -- lang-select
///  ```
///
///  Output:
///  ```plaintext
///  Selected: OCaml (A representative functional programming language with strong type inference)
///  Selected: Rust (A systems programming language focused on performance, safety, and concurrency)
///  ```
///
/// Source code (./Cargo.toml)
/// ```toml
/// [package]
/// name = "example-enum-tag"
/// version = "0.1.0"
/// edition = "2024"
///
/// [dependencies.mingling]
/// path = "../../mingling"
///
/// features = [
///     "comp",
///     "parser"
/// ]
/// ```
///
/// Source code (./src/main.rs)
/// ```ignore
/// use mingling::{
///     macros::suggest_enum, parser::PickableEnum, prelude::*, EnumTag, Groupped, ShellContext,
///     Suggest,
/// };
///
/// // Define the enum and derive the EnumTag trait
/// //                        ________ adds metadata to the enum, enabling it to:
/// //                       /         1. Be used by the `suggest_enum!(Enum)` macro under the `comp` feature for autocompletion
/// //                       vvvvvvv   2. Implement the `PickableEnum` trait
/// #[derive(Debug, Default, EnumTag, Groupped)]
/// pub enum ProgrammingLanguages {
///     #[enum_desc("An efficient and flexible compiled language widely used for system programming")]
///     C,
///
///     #[enum_rename("C++")]
///     #[enum_desc("A high-performance language extending C with object-oriented features")]
///     CPlusPlus,
///
///     #[enum_rename("C#")]
///     #[enum_desc("Microsoft's object-oriented programming language running on the .NET platform")]
///     Csharp,
///
///     #[enum_desc(
///         "A cross-platform object-oriented language widely used for enterprise application development"
///     )]
///     Java,
///
///     #[enum_desc(
///         "A dynamic scripting language for web development, supporting prototype chain inheritance"
///     )]
///     JavaScript,
///
///     #[enum_desc("A modern statically typed language running on the JVM, concise and safe")]
///     Kotlin,
///
///     #[enum_desc("A representative functional programming language with strong type inference")]
///     OCaml,
///
///     #[enum_desc("A general-purpose programming language with clean syntax, known for readability")]
///     Python,
///
///     #[enum_desc(
///         "An object-oriented scripting language, famous for its concise and elegant syntax"
///     )]
///     Ruby,
///
///     #[default]
///     #[enum_desc("A systems programming language focused on performance, safety, and concurrency")]
///     Rust,
/// }
///
/// // --------- IMPORTANT ---------
/// // Implement the PickableEnum trait for ProgrammingLanguages,
/// // so that `Picker` can parse this enum
/// impl PickableEnum for ProgrammingLanguages {}
/// // --------- IMPORTANT ---------
///
/// dispatcher!("lang-select", CMDLanguageSelection => EntryLanguageSelection);
///
/// #[chain]
/// fn handle_language_selection(args: EntryLanguageSelection) -> Next {
///     // You can use Picker to directly parse ProgrammingLanguages
///     let lang: ProgrammingLanguages = args.pick(()).unpack();
///     lang
/// }
///
/// /// Renders the selected programming language with its name and description.
/// #[renderer]
/// fn render_programming_language(lang: ProgrammingLanguages) {
///     // You can use `enum_info()` to get the name and description of the current enum
///     let (name, desc) = lang.enum_info();
///     r_println!("Selected: {} ({})", name, desc)
/// }
///
/// #[completion(EntryLanguageSelection)]
/// fn complete_language_selection(_: &ShellContext) -> Suggest {
///     // Use `suggest_enum!` directly to generate enum suggestions
///     suggest_enum!(ProgrammingLanguages)
/// }
///
/// gen_program!();
///
/// fn main() {
///     let mut program = ThisProgram::new();
///     program.with_dispatcher(CMDCompletion);
///     program.with_dispatcher(CMDLanguageSelection);
///     program.exec_and_exit();
/// }
/// ```
pub mod example_enum_tag {}
/// Example Error Handling
///
///  > This example demonstrates how to handle errors in Mingling, including custom error types and error rendering.
///
///  Run:
///  ```bash
///  cargo run --manifest-path examples/example-error-handling/Cargo.toml --quiet -- hallo
///  cargo run --manifest-path examples/example-error-handling/Cargo.toml --quiet -- hello
///  cargo run --manifest-path examples/example-error-handling/Cargo.toml --quiet -- hello Alice
///  cargo run --manifest-path examples/example-error-handling/Cargo.toml --quiet -- hello MyBestFriendAlice
///  cargo run --manifest-path examples/example-error-handling/Cargo.toml --quiet -- hello Peter
///  ```
///
///  Output:
///  ```plaintext
///  Command not found: "hallo"
///  No name provided
///  Name not available
///  Name too long: 17 > 10
///  Hello, Peter
///  ```
///
/// Source code (./Cargo.toml)
/// ```toml
/// [package]
/// name = "example-error-handling"
/// version = "0.1.0"
/// edition = "2024"
///
/// [dependencies]
/// mingling = { path = "../../mingling" }
/// ```
///
/// Source code (./src/main.rs)
/// ```ignore
/// use mingling::prelude::*;
///
/// // In Mingling, instead of using ? to propagate errors upward,
/// // errors are treated as branches that continue execution.
///
/// dispatcher!("hello", CMDHello => EntryHello);
///
/// // Define error types
/// pack!(ErrorNoNameProvided = ());
/// pack!(ErrorNameTooLong = u16);
/// pack!(ErrorNameNotAvailable = ());
///
/// // Define success type
/// pack!(ResultName = String);
///
/// // Pre-registered names
/// static VEC_REGISTERED_NAMES: &[&str] = &["Alice", "Bob", "Charlie", "David", "Eve"];
///
/// #[chain]
/// fn handle_hello(args: EntryHello) -> Next {
///     let Some(name) = args.inner.first().cloned() else {
///         // If no name is provided, pass ErrorNoNameProvided
///         return ErrorNoNameProvided::default().to_render();
///     };
///
///     if name.len() > 10 {
///         // If the name is too long, pass ErrorNameTooLong
///         return ErrorNameTooLong::new(name.len() as u16).to_render();
///     }
///
///     if VEC_REGISTERED_NAMES.contains(&name.as_str()) {
///         // If the name already exists, pass ErrorNameNotAvailable
///         return ErrorNameNotAvailable::default().to_render();
///     }
///
///     // If the name is valid, pass ResultName
///     ResultName::new(name).to_render()
/// }
///
/// /// Renders a successful greeting with the given name.
/// #[renderer]
/// fn render_result_name(name: ResultName) {
///     r_println!("Hello, {}", *name);
/// }
///
/// /// Renders the error when no name is provided.
/// #[renderer]
/// fn render_error_no_name_provided(_: ErrorNoNameProvided) {
///     // Prompt when no name is provided
///     r_println!("No name provided");
/// }
///
/// /// Renders the error when the name is already taken.
/// #[renderer]
/// fn render_error_name_not_available(_: ErrorNameNotAvailable) {
///     // Prompt when name is already taken
///     r_println!("Name not available");
/// }
///
/// /// Renders the error when the name exceeds the maximum length.
/// #[renderer]
/// fn render_error_name_too_long(len: ErrorNameTooLong) {
///     // Prompt when name is too long, showing actual length
///     r_println!("Name too long: {} > 10", *len);
/// }
///
/// /// Renders the error when the dispatcher (subcommand) is not found.
/// #[renderer]
/// fn render_dispatcher_not_found(err: ErrorDispatcherNotFound) {
///     // Prompt when command is not found, showing the input command
///     r_println!("Command not found: \"{}\"", err.inner.join(" "));
/// }
///
/// gen_program!();
///
/// fn main() {
///     let mut program = ThisProgram::new();
///     program.with_dispatcher(CMDHello);
///     program.exec_and_exit();
/// }
/// ```
pub mod example_error_handling {}
/// Example Error Handling
///
///  > This example demonstrates how to handle errors in Mingling, including custom error types and error rendering.
///
///  Run:
///  ```bash
///  cargo run --manifest-path examples/example-exitcode/Cargo.toml --quiet -- hello Alice
///  cargo run --manifest-path examples/example-exitcode/Cargo.toml --quiet -- hello
///  ```
///
///  Output:
///  ```plaintext
///  Hello, Alice
///  No name provided (with exit code 1)
///  ```
///
/// Source code (./Cargo.toml)
/// ```toml
/// [package]
/// name = "example-exitcode"
/// version = "0.1.0"
/// edition = "2024"
///
/// [dependencies]
/// mingling = { path = "../../mingling" }
/// ```
///
/// Source code (./src/main.rs)
/// ```ignore
/// use mingling::{prelude::*, res::ExitCode, setup::ExitCodeSetup};
///
/// fn main() {
///     let mut program = ThisProgram::new();
///
///     // --------- IMPORTANT ---------
///     // Register `ExitCodeSetup` for the program to enable exit codes
///     program.with_setup(ExitCodeSetup::default());
///     // --------- IMPORTANT ---------
///
///     program.with_dispatcher(CMDHello);
///     program.exec_and_exit();
/// }
///
/// dispatcher!("hello", CMDHello => EntryHello);
///
/// pack!(ErrorNoNameProvided = ());
/// pack!(ResultName = String);
///
/// #[chain]
/// fn handle_hello(args: EntryHello) -> Next {
///     let Some(name) = args.inner.first().cloned() else {
///         // If no name is provided, pass ErrorNoNameProvided
///         return ErrorNoNameProvided::default().to_render();
///     };
///
///     // If the name is valid, pass ResultName
///     ResultName::new(name).to_render()
/// }
///
/// /// Renders a successful greeting with the given name.
/// #[renderer]
/// fn render_result_name(name: ResultName) {
///     r_println!("Hello, {}", *name);
/// }
///
/// // Define renderer, render error message                      _____________ Inject exit code resource
/// //                                                           /
/// /// Renders the error when no name is provided               |
/// #[renderer] //                                               vvvvvvvvvvvvv
/// fn render_error_no_name_provided(_: ErrorNoNameProvided, ec: &mut ExitCode) {
///     ec.exit_code = 1;
///
///     // Prompt when no name is provided
///     r_println!("No name provided (with exit code 1)");
/// }
///
/// gen_program!();
/// ```
pub mod example_exitcode {}
/// Example General Renderer
///
///  > This example demonstrates how to use the `general_renderer` feature to render data into structures such as json / yaml
///
///  Run
///  ```bash
///  cargo run --manifest-path examples/example-general-renderer/Cargo.toml --quiet -- render Bob 22
///  cargo run --manifest-path examples/example-general-renderer/Cargo.toml --quiet -- render Bob 22 --json
///  cargo run --manifest-path examples/example-general-renderer/Cargo.toml --quiet -- render Bob 22 --yaml
///  ```
///
///  Output:
///  ```plain
///  Bob is 22 years old
///  {"member_name":"Bob","member_age":22}
///  member_name: Bob
///  member_age: 22
///  ```
///
/// Source code (./Cargo.toml)
/// ```toml
/// [package]
/// name = "example-general-renderer"
/// version = "0.1.0"
/// edition = "2024"
///
/// [dependencies]
/// serde = { version = "1.0.228", features = ["derive"] }
///
/// [dependencies.mingling]
/// path = "../../mingling"
/// features = [
///     "general_renderer",
///     "parser",
/// ]
/// ```
///
/// Source code (./src/main.rs)
/// ```ignore
/// use mingling::prelude::*;
/// use mingling::{parser::Picker, setup::GeneralRendererSetup, Groupped};
/// use serde::Serialize;
///
/// dispatcher!("render", CMDRender => EntryRender);
///
/// fn main() {
///     let mut program = ThisProgram::new();
///     // Add `GeneralRendererSetup` to receive user input `--json` `--yaml` parameters
///     program.with_setup(GeneralRendererSetup);
///     program.with_dispatcher(CMDRender);
///     let _ = program.exec();
/// }
///
/// // --------- IMPORTANT ---------
/// // For beautiful output structure, do not use `pack!` to wrap the types that need to be output.
/// // Instead, manually implement
/// //        ____________________ Implement serde::Serialize
/// //       /           _________ Implement mingling::Groupped
/// //       |          /            to ensure Mingling can recognize the type
/// //       vvvvvvvvv  vvvvvvvv
/// #[derive(Serialize, Groupped)]
/// struct Info {
///     #[serde(rename = "member_name")]
///     name: String,
///     #[serde(rename = "member_age")]
///     age: i32,
/// }
/// // This will output: {"member_name":"name","member_age":32} structure
///
/// // If using pack!(Info = (String, i32));
/// // Output: {"inner":["name", 32]}
///
/// // --------- IMPORTANT ---------
///
/// #[chain]
/// fn parse_render(prev: EntryRender) -> Next {
///     let (name, age) = Picker::new(prev.inner)
///         .pick::<String>(())
///         .pick::<i32>(())
///         .unpack();
///     Info { name, age }.to_render()
/// }
///
/// /// Implement default renderer for when general_renderer is not specified
/// #[renderer]
/// fn render_info(prev: Info) {
///     r_println!("{} is {} years old", prev.name, prev.age);
/// }
///
/// gen_program!();
/// ```
pub mod example_general_renderer {}
/// Example Help
///
///  > This example demonstrates how to use the `#[help]` macro to generate help information,
///  > enabling `--help` to work
///
///  Run
///  ```bash
///  cargo run --manifest-path examples/example-help/Cargo.toml --quiet -- greet --help
///  ```
///
///  Output:
///  ```plain
///  Usage: greet <NAME>
///  ```
///
/// Source code (./Cargo.toml)
/// ```toml
/// [package]
/// name = "example-help"
/// version = "0.1.0"
/// edition = "2024"
///
/// [dependencies]
/// mingling = { path = "../../mingling" }
/// ```
///
/// Source code (./src/main.rs)
/// ```ignore
/// use mingling::{macros::help, prelude::*, setup::BasicProgramSetup};
///
/// dispatcher!("greet", CMDGreet => EntryGreet);
///
/// // Define help        _________ When `program.user_context.help` is `true`
/// //                   /            the command will not enter `#[chain]` / `#[renderer]`
/// #[help] //           vvvvvvvvvv   but instead enter this `#[help]` function
/// fn help_greet(_prev: EntryGreet) {
///     r_println!("Usage: greet <NAME>");
/// }
///
/// fn main() {
///     let mut program = ThisProgram::new();
///
///     // --------- IMPORTANT ---------
///     // Add `BasicProgramSetup` to the program
///     // to enable `--help`, `--quiet`, and other built-in features
///     program.with_setup(BasicProgramSetup);
///     // --------- IMPORTANT ---------
///
///     program.with_dispatcher(CMDGreet);
///
///     program.exec_and_exit();
/// }
///
/// gen_program!();
/// ```
pub mod example_help {}
/// Example Hook
///
///  > This example demonstrates how to use Mingling's hook system to obtain debugging information during program execution
///
///  Run:
///  ```base
///  cargo run --manifest-path examples/example-hook/Cargo.toml --quiet -- greet Alice
///  ```
///
///  Output:
///  ```plaintext
///  [DEBUG] Program is begin
///  [DEBUG] Pre dispatch: ["greet", "Alice"]
///  [DEBUG] Post dispatch: EntryGreet
///  [DEBUG] Pre chain: EntryGreet
///  [DEBUG] Post chain: ResultName
///  [DEBUG] Pre render: ResultName
///  [DEBUG] Post render
///  [DEBUG] Program end
///  Hello, Alice!
///  ```
///
/// Source code (./Cargo.toml)
/// ```toml
/// [package]
/// name = "example-hook"
/// version = "0.1.0"
/// edition = "2024"
///
/// [dependencies]
/// mingling = { path = "../../mingling" }
/// ```
///
/// Source code (./src/main.rs)
/// ```ignore
/// use mingling::{hook::ProgramHook, prelude::*};
///
/// dispatcher!("greet", CMDGreet => EntryGreet);
///
/// fn main() {
///     let mut program = ThisProgram::new();
///
///     // --------- IMPORTANT ---------
///     program.with_hook(
///         ProgramHook::<ThisProgram>::empty()
///             .on_begin(|| println!("[DEBUG] Program is begin"))
///             .on_pre_dispatch(|args| println!("[DEBUG] Pre dispatch: {args:?}"))
///             .on_post_dispatch(|c: &_| println!("[DEBUG] Post dispatch: {c:?}"))
///             .on_pre_chain(|c: &_, _| {
///                 println!("[DEBUG] Pre chain: {c}");
///             })
///             .on_post_chain(|any_output| println!("[DEBUG] Post chain: {}", any_output.member_id))
///             .on_finish(|| {
///                 println!("[DEBUG] Loop end");
///                 0 // Override exit code
///             })
///             .on_pre_render(|c: &_, _| println!("[DEBUG] Pre render: {c}"))
///             .on_post_render(|_| println!("[DEBUG] Post render")),
///     );
///     // --------- IMPORTANT ---------
///
///     program.with_dispatcher(CMDGreet);
///     program.exec_and_exit();
/// }
///
/// pack!(ResultName = String);
///
/// #[chain]
/// fn handle_greet(args: EntryGreet) -> Next {
///     let name: ResultName = args
///         .inner
///         .first()
///         .cloned()
///         .unwrap_or_else(|| "World".to_string())
///         .into();
///     name
/// }
///
/// /// Renders the greeting message with the provided name.
/// #[renderer]
/// fn render_name(name: ResultName) {
///     r_println!("Hello, {}!", *name);
/// }
///
/// gen_program!();
/// ```
pub mod example_hook {}
/// Example Implicit Dispatcher
///
///  > This example demonstrates how to use the implicit `dispatcher!` definition syntax enabled by `extra_macros`
///
/// Source code (./Cargo.toml)
/// ```toml
/// [package]
/// name = "example-implicit-dispatcher"
/// version = "0.1.0"
/// edition = "2024"
///
/// [dependencies.mingling]
/// path = "../../mingling"
/// features = ["extra_macros"]
/// ```
///
/// Source code (./src/main.rs)
/// ```ignore
/// use mingling::prelude::*;
///
/// // When using implicit syntax, the entry and dispatcher names will be automatically derived
/// dispatcher!("remote.add" /*, CMDRemoteAdd    => EntryRemoteAdd */);
/// dispatcher!("remote.remove", CMDRemoteRemove => EntryRemoteRemove);
///
/// fn main() {
///     let mut program = ThisProgram::new();
///
///     // --------- IMPORTANT ---------
///     program.with_dispatcher(CMDRemoteAdd);
///     //                      ^^^^^^^^^^^^\_ CMDRemoteAdd is implicitly created
///     // --------- IMPORTANT ---------
///
///     program.with_dispatcher(CMDRemoteRemove);
///     program.exec_and_exit();
/// }
///
/// gen_program!();
/// ```
pub mod example_implicit_dispatcher {}
/// Example Panic Unwind
///
///  > This example introduces how to catch Panic in the Mingling program loop
///
///  Run:
///  ```bash
///  cargo run --manifest-path examples/example-panic-unwind/Cargo.toml --quiet -- panic
///  cargo run --manifest-path examples/example-panic-unwind/Cargo.toml --quiet -- panic OhMyGod
///  ```
///
///  Output:
///  ```plaintext
///  Program not panic
///  Program panic: OhMyGod
///  OhMyGod
///  ```
///
/// Source code (./Cargo.toml)
/// ```toml
/// [package]
/// name = "example-panic-unwind"
/// version = "0.1.0"
/// edition = "2024"
///
/// [dependencies.mingling]
/// path = "../../mingling"
/// features = ["parser"]
///
/// # Enable panic unwinding in release builds
/// [profile.release]
/// panic = "unwind"
///
/// # Enable panic unwinding in dev builds
/// [profile.dev]
/// panic = "unwind"
/// ```
///
/// Source code (./src/main.rs)
/// ```ignore
/// use mingling::{hook::ProgramHook, prelude::*};
///
/// dispatcher!("panic", CMDPanic => EntryPanic);
/// pack!(NotPanic = ());
///
/// fn main() {
///     let mut program = ThisProgram::new();
///     program.with_dispatcher(CMDPanic);
///
///     // --------- IMPORTANT ---------
///     // Enable silence_panic to suppress automatic Panic output
///     program.stdout_setting.silence_panic = true;
///
///     // Define a hook to output &ProgramPanic when a Panic occurs
///     program.with_hook(ProgramHook::empty().on_exec_panic(|info| println!("Program panic: {info}")));
///     // --------- IMPORTANT ---------
///
///     let _ = program.exec();
/// }
///
/// #[chain]
/// fn handle_panic(prev: EntryPanic) -> Next {
///     let panic_info = prev.pick::<Option<String>>(()).unpack();
///     match panic_info {
///         Some(s) => {
///             // Panic happens here, will be caught
///             panic!("{}", s)
///         }
///         None => NotPanic::default(),
///     }
/// }
///
/// /// Renders the message when no panic occurs.
/// #[renderer]
/// fn render(_: NotPanic) {
///     r_println!("Program not panic");
/// }
///
/// gen_program!();
/// ```
pub mod example_panic_unwind {}
/// Example REPL Basic
///
///  > This example demonstrates how to develop a REPL program using the `repl` feature
///
///  Run:
///  ```bash
///  cargo run --manifest-path examples/example-repl-basic/Cargo.toml --quiet
///  ```
///
/// Source code (./Cargo.toml)
/// ```toml
/// [package]
/// name = "example-repl-basic"
/// version = "0.1.0"
/// edition = "2024"
///
/// [dependencies.mingling]
/// path = "../../mingling"
/// features = ["repl", "parser", "extra_macros"]
///
/// [dependencies]
/// just_fmt = "0.1.2"
/// ```
///
/// Source code (./src/main.rs)
/// ```ignore
/// use mingling::{
///     hook::ProgramHook,
///     prelude::*,
///     setup::{BasicREPLOutputSetup, BasicREPLPromptSetup, BasicREPLReadlineSetup},
///     this, REPL,
/// };
/// use std::{env::current_dir, path::PathBuf};
///
/// // Resource to store the current directory
/// #[derive(Clone)]
/// struct ResCurrentDir {
///     dir: PathBuf,
/// }
///
/// impl Default for ResCurrentDir {
///     fn default() -> Self {
///         Self {
///             dir: current_dir().unwrap(),
///         }
///     }
/// }
///
/// fn main() {
///     let mut program = ThisProgram::new();
///
///     // Resource
///     program.with_resource(ResCurrentDir::default());
///
///     // Dispatchers
///     program.with_dispatcher(CMDCd);
///     program.with_dispatcher(CMDLs);
///     program.with_dispatcher(CMDExit);
///     program.with_dispatcher(CMDClear);
///
///     // Setups
///     // Enable basic std::io::stdin().read_line(&mut input)
///     program.with_setup(BasicREPLReadlineSetup);
///
///     // Enable basic output, using println! after Renderer finishes drawing
///     program.with_setup(BasicREPLOutputSetup);
///
///     // Enable basic Prompt display, with custom display logic
///     program.with_setup(BasicREPLPromptSetup::func(|| {
///         // Get the ResCurrentDir resource from the program
///         let res = this::<ThisProgram>().res::<ResCurrentDir>().unwrap();
///         let dir_str: String = res.dir.to_string_lossy().into();
///         let prompt = format!(
///             "{}> ",
///             dir_str
///                 .replace(&['/', '\\'][..], ">")
///                 .trim_start_matches('>')
///                 .trim_end_matches('>')
///         );
///         prompt
///     }));
///
///     // Add hooks to handle REPL-related events
///     program.with_hook(ProgramHook::empty().on_repl_begin(|| {
///         // Print welcome message
///         println!("Welcome!");
///     }));
///
///     // Start the REPL loop
///     program.exec_repl();
/// }
///
/// // Create error route
/// pack!(ErrorDirectoryNotExist = PathBuf);
///
/// // Create commands: cd ls exit
/// dispatcher!("cd", CMDCd => EntryCd);
/// dispatcher!("ls", CMDLs => EntryLs);
/// dispatcher!("exit", CMDExit => EntryExit);
/// dispatcher!("clear", CMDClear => EntryClear);
///
/// // Define data needed for the cd command's execution phase
/// pack!(StateChangeDirectory = String);
///
/// // Define data needed for the ls command's rendering phase
/// pack!(ResultList = Vec<String>);
///
/// // Parse cd command arguments
/// #[chain]
/// fn parse_cd_args(prev: EntryCd) -> Next {
///     let join = prev.pick(()).unpack();
///     StateChangeDirectory::new(join)
/// }
///
/// // Execute directory change
/// #[chain]
/// fn handle_cd(prev: StateChangeDirectory, current_dir: &mut ResCurrentDir) -> Next {
///     use just_fmt::fmt_path::fmt_path;
///
///     let join = prev.inner;
///     let new_dir = fmt_path(current_dir.dir.join(join)).unwrap_or_default();
///
///     // If the path is not found, route to error handling
///     if !new_dir.exists() {
///         return ErrorDirectoryNotExist::new(new_dir).to_render();
///     }
///
///     current_dir.dir = new_dir;
///     empty_result!()
/// }
///
/// // Get directory contents via the CurrentDir resource
/// #[chain]
/// fn handle_ls(_prev: EntryLs, current_dir: &ResCurrentDir) -> Next {
///     let dir = &current_dir.dir;
///     let entries: Vec<String> = std::fs::read_dir(dir)
///         .into_iter()
///         .flat_map(|rd| rd.filter_map(std::result::Result::ok))
///         .map(|e| {
///             let name = e.file_name().to_string_lossy().to_string();
///             if e.file_type().map(|t| t.is_dir()).unwrap_or(false) {
///                 format!("{name}/")
///             } else {
///                 name
///             }
///         })
///         .collect();
///
///     // Render ResultList
///     ResultList::new(entries).to_render()
/// }
///
/// /// Render ResultList data
/// #[renderer]
/// fn render_list(list: ResultList) {
///     for item in list.inner {
///         r_println!("{}", item);
///     }
/// }
///
/// // Handle exit command event
/// #[chain]
/// fn handle_exit(
///     _prev: EntryExit,
///     repl: &mut REPL, // Import REPL resource, registered in `exec_repl`, usable directly
/// ) {
///     // Set the REPL exit flag; REPL will exit after this loop iteration
///     repl.exit = true;
/// }
///
/// /// Handle clear command event
/// #[chain]
/// fn handle_clear(_prev: EntryClear) {
///     // Clear the terminal screen
///     print!("\x1B[2J\x1B[1;1H");
/// }
///
/// /// Handle path not found event
/// #[renderer]
/// fn render_error_directory_not_exist(err: ErrorDirectoryNotExist) {
///     r_println!("Directory not found: {}", err.inner.display())
/// }
///
/// /// Handle dispatcher not found event
/// /// Renders the error when a command is not found.
/// #[renderer]
/// fn dispatcher_not_found(prev: ErrorDispatcherNotFound) {
///     r_println!("Command not found: \"{}\"", prev.join(", "))
/// }
///
/// gen_program!();
/// ```
pub mod example_repl_basic {}
/// Example Resource Injection
///
///  > This example demonstrates how to read and write the program's global state using Mingling's resource system
///
///  Run:
///  ```bash
///  cargo run --manifest-path examples/example-resources/Cargo.toml --quiet current
///  cargo run --manifest-path examples/example-resources/Cargo.toml --quiet modify-current src
///  ```
///
///  Output:
///  ```plaintext
///  Current directory: /home/alice/mingling
///  Current directory: /home/alice/mingling/src
///  ```
///
/// Source code (./Cargo.toml)
/// ```toml
/// [package]
/// name = "example-resources"
/// version = "0.1.0"
/// edition = "2024"
///
/// [dependencies.mingling]
/// path = "../../mingling"
/// features = ["parser"]
/// ```
///
/// Source code (./src/main.rs)
/// ```ignore
/// use std::path::PathBuf;
///
/// use mingling::prelude::*;
///
/// // Create resource
/// //        ______________ Resource needs to
/// //       /        /        implement the following two traits
/// //       vvvvvvv  vvvvv
/// #[derive(Default, Clone)]
/// struct ResCurrentDir {
///     current_dir: PathBuf,
/// }
///
/// fn main() {
///     let mut program = ThisProgram::new();
///
///     // --------- IMPORTANT ---------
///     // Use `with_resource` to inject a singleton into the program
///     program.with_resource(ResCurrentDir {
///         current_dir: std::env::current_dir().unwrap(),
///     });
///     // --------- IMPORTANT ---------
///
///     program.with_dispatchers((CMDCurrent, CMDModifyCurrent));
///     program.exec_and_exit();
/// }
///
/// dispatcher!("current", CMDCurrent => EntryCurrent);
/// dispatcher!("modify-current", CMDModifyCurrent => EntryModifyCurrent);
///
/// // Define chain for modifying current directory                  _________________ Injected muttable resource
/// //                                                              /
/// #[chain] //                                                     vvvvvvvvvvvvvvvvvv
/// fn render_modify_current(args: EntryModifyCurrent, current_dir: &mut ResCurrentDir) -> Next {
///     current_dir.current_dir = current_dir
///         .current_dir
///         .join(args.pick::<String>(()).unpack());
///     EntryCurrent::default()
/// }
///
/// // Define renderer for output current path       _____________ Injected resource
/// //                                              /
/// /// Renders the current directory path.         |
/// #[renderer] //                                  vvvvvvvvvvvvvv
/// fn render_current(_: EntryCurrent, current_dir: &ResCurrentDir) {
///     r_println!("Current directory: {}", current_dir.current_dir.display());
/// }
///
/// gen_program!();
/// ```
pub mod example_resources {}
/// Example Setup
///
///  > This example demonstrates how to build a custom Setup for modular management of project components
///
/// Source code (./Cargo.toml)
/// ```toml
/// [package]
/// name = "example-setup"
/// version = "0.1.0"
/// edition = "2024"
///
/// [dependencies]
/// mingling = { path = "../../mingling", features = ["extra_macros"] }
/// ```
///
/// Source code (./src/main.rs)
/// ```ignore
/// use mingling::{macros::program_setup, prelude::*, Program};
///
/// 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!();
/// ```
pub mod example_setup {}
/// Example Unit Test
///
///  > This example shows how to write unit tests for Chain and Renderer in Mingling
///
///  ```bash
///  cargo test --manifest-path examples/example-unit-test/Cargo.toml
///  ```
///
/// Source code (./Cargo.toml)
/// ```toml
/// [package]
/// name = "example-unit-test"
/// version = "0.1.0"
/// edition = "2024"
///
/// [dependencies]
/// mingling = { path = "../../mingling", features = ["extra_macros"] }
/// ```
///
/// Source code (./src/main.rs)
/// ```ignore
/// use mingling::prelude::*;
///
/// #[cfg(test)]
/// mod tests {
///     use super::*;
///     use mingling::macros::entry;
///     use mingling::{assert_member_id, assert_render_result};
///
///     // --------- IMPORTANT ---------
///     #[test]
///     fn test_handle_hello() {
///         let hello_without_args = handle_hello(entry!()).into();
///         assert_render_result!(hello_without_args);
///         assert_member_id!(hello_without_args, ThisProgram::ErrorNoNameProvided);
///
///         let hello_with_registered_name = handle_hello(entry!("Alice")).into();
///         assert_render_result!(hello_with_registered_name);
///         assert_member_id!(
///             hello_with_registered_name,
///             ThisProgram::ErrorNameNotAvailable
///         );
///
///         let hello_with_long_name = handle_hello(entry!("It's a VeryLongName")).into();
///         assert_render_result!(hello_with_long_name);
///         assert_member_id!(hello_with_long_name, ThisProgram::ErrorNameTooLong);
///
///         let hello_with_valid_name = handle_hello(entry!("Peter")).into();
///         assert_render_result!(hello_with_valid_name);
///     }
///
///     #[test]
///     fn test_render_result_name() {
///         let r = render_result_name(ResultName::new("Peter".into()));
///         assert_eq!(r, "Hello, Peter!\n")
///     }
///
///     #[test]
///     fn test_render_error_no_name_provided() {
///         let r = render_error_no_name_provided(ErrorNoNameProvided::default());
///         assert_eq!(r, "No name provided\n")
///     }
///
///     #[test]
///     fn test_render_error_name_not_available() {
///         let r = render_error_name_not_available(ErrorNameNotAvailable::default());
///         assert_eq!(r, "Name not available\n")
///     }
///
///     #[test]
///     fn test_render_error_name_too_long() {
///         let r = render_error_name_too_long(ErrorNameTooLong::new(17));
///         assert_eq!(r, "Name too long: 17 > 10\n")
///     }
///     // --------- IMPORTANT ---------
/// }
///
/// dispatcher!("hello", CMDHello => EntryHello);
///
/// pack!(ErrorNoNameProvided = ());
/// pack!(ErrorNameTooLong = u16);
/// pack!(ErrorNameNotAvailable = ());
///
/// pack!(ResultName = String);
///
/// static VEC_REGISTERED_NAMES: &[&str] = &["Alice", "Bob", "Charlie", "David", "Eve"];
///
/// #[chain]
/// fn handle_hello(args: EntryHello) -> Next {
///     let Some(name) = args.inner.first().cloned() else {
///         return ErrorNoNameProvided::default().to_render();
///     };
///
///     if name.len() > 10 {
///         return ErrorNameTooLong::new(name.len() as u16).to_render();
///     }
///
///     if VEC_REGISTERED_NAMES.contains(&name.as_str()) {
///         return ErrorNameNotAvailable::default().to_render();
///     }
///
///     ResultName::new(name).to_render()
/// }
///
/// /// Renders a successful greeting with the given name.
/// #[renderer]
/// fn render_result_name(name: ResultName) -> String {
///     r_println!("Hello, {}!", *name);
/// }
///
/// /// Renders the error when no name is provided.
/// #[renderer]
/// fn render_error_no_name_provided(_: ErrorNoNameProvided) -> String {
///     r_println!("No name provided");
/// }
///
/// /// Renders the error when the name is already taken.
/// #[renderer]
/// fn render_error_name_not_available(_: ErrorNameNotAvailable) -> String {
///     r_println!("Name not available");
/// }
///
/// /// Renders the error when the name exceeds the maximum length.
/// #[renderer]
/// fn render_error_name_too_long(len: ErrorNameTooLong) -> String {
///     r_println!("Name too long: {} > 10", *len);
/// }
///
/// /// Renders the error when the dispatcher (subcommand) is not found.
/// #[renderer]
/// fn render_dispatcher_not_found(err: ErrorDispatcherNotFound) {
///     r_println!("Command not found: \"{}\"", err.inner.join(" "));
/// }
///
/// gen_program!();
///
/// fn main() {
///     let mut program = ThisProgram::new();
///     program.with_dispatcher(CMDHello);
///     program.exec_and_exit();
/// }
/// ```
pub mod example_unit_test {}