diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-06-30 04:45:04 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-06-30 04:45:04 +0800 |
| commit | 69e5fd86b4532d3dfa7c503f74d42a64a845d57e (patch) | |
| tree | 41831b777027bf4d765249a4dd41446b37634764 /mingling_pathf/test | |
| parent | 5b1593afa467df256fcd7076967d305bebbb21ee (diff) | |
fix(mingling_pathf): extract CMD, error, and help types from
dispatcher_clap
Diffstat (limited to 'mingling_pathf/test')
| -rw-r--r-- | mingling_pathf/test/Cargo.lock | 1 | ||||
| -rw-r--r-- | mingling_pathf/test/src/lib.rs | 29 | ||||
| -rw-r--r-- | mingling_pathf/test/src/test_files/test_dispatcher_clap.rs | 40 |
3 files changed, 70 insertions, 0 deletions
diff --git a/mingling_pathf/test/Cargo.lock b/mingling_pathf/test/Cargo.lock index 6c89ae3..e5fd23a 100644 --- a/mingling_pathf/test/Cargo.lock +++ b/mingling_pathf/test/Cargo.lock @@ -12,6 +12,7 @@ checksum = "5454cda0d57db59778608d7a47bff5b16c6705598265869fb052b657f66cf05e" name = "mingling_pathf" version = "0.2.0" dependencies = [ + "just_fmt", "proc-macro2", "syn", ] diff --git a/mingling_pathf/test/src/lib.rs b/mingling_pathf/test/src/lib.rs index 51e19a6..6fce3b2 100644 --- a/mingling_pathf/test/src/lib.rs +++ b/mingling_pathf/test/src/lib.rs @@ -315,12 +315,41 @@ fn test_dispatcher_clap_analyze() { let r = analyzer.analyze_file(file).unwrap(); let required: Vec<&str> = vec![ + // Root: entry types (bare dispatcher_clap, no params) "::EntryClap1", "::EntryClap2", "::EntryClap3", "::EntryClap4", + // Root: with CMD type + "::EntryWithCmd", + "::CMDGreet", + // Root: with CMD + error + "::EntryWithError", + "::CMDDelete", + "::ErrorDelete", + // Root: with CMD + help + "::EntryWithHelp", + "::CMDHelp", + "::__internal_help_cmdhelp_help", + // Root: with CMD + error + help + "::EntryFull", + "::CMDFull", + "::ErrorFull", + "::__internal_help_cmdfull_help", + // Sub: entry types (bare dispatcher_clap) "::sub::EntryClap1", "::sub::EntryClap3", + // Sub: with CMD type + "::sub::EntryWithCmd", + "::sub::CMDGreet", + // Sub: with CMD + error + "::sub::EntryWithError", + "::sub::CMDDelete", + "::sub::ErrorDelete", + // Sub: with CMD + help + "::sub::EntryWithHelp", + "::sub::CMDHelp", + "::sub::__internal_help_cmdhelp_help", ]; assert_eq!(r.len(), required.len()); diff --git a/mingling_pathf/test/src/test_files/test_dispatcher_clap.rs b/mingling_pathf/test/src/test_files/test_dispatcher_clap.rs index 0ba884d..33d86e0 100644 --- a/mingling_pathf/test/src/test_files/test_dispatcher_clap.rs +++ b/mingling_pathf/test/src/test_files/test_dispatcher_clap.rs @@ -1,3 +1,4 @@ +// Basic: entry type only (no CMD type specified) #[mingling::macros::dispatcher_clap] struct EntryClap1 { name: String, @@ -20,6 +21,30 @@ pub struct EntryClap4 { value: i32, } +// With CMD type +#[dispatcher_clap("greet", CMDGreet)] +struct EntryWithCmd { + name: String, +} + +// With CMD + error +#[dispatcher_clap("delete", CMDDelete, error = ErrorDelete)] +struct EntryWithError { + id: u64, +} + +// With CMD + help +#[dispatcher_clap("helpcmd", CMDHelp, help = true)] +struct EntryWithHelp { + verbose: bool, +} + +// With CMD + error + help +#[dispatcher_clap("full", CMDFull, error = ErrorFull, help = true)] +struct EntryFull { + all: bool, +} + pub mod sub { #[mingling::macros::dispatcher_clap] struct EntryClap1 { @@ -30,4 +55,19 @@ pub mod sub { struct EntryClap3 { value: String, } + + #[dispatcher_clap("greet", CMDGreet)] + struct EntryWithCmd { + name: String, + } + + #[dispatcher_clap("delete", CMDDelete, error = ErrorDelete)] + struct EntryWithError { + id: u64, + } + + #[dispatcher_clap("helpcmd", CMDHelp, help = true)] + struct EntryWithHelp { + verbose: bool, + } } |
