diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-05-29 16:49:35 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-05-29 16:49:35 +0800 |
| commit | 2c5355555126cf0e5e6012fb22457638bce9bf4d (patch) | |
| tree | 020f0006f99655d81941ea1f2e718747ce0a5d33 /examples | |
| parent | c8d5b062a8f6ef0141e164e8d0249fa1c1d3bd98 (diff) | |
Rename CompletionDispatcher to CMDCompletion and hide internal types
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/example-completion/src/main.rs | 8 | ||||
| -rw-r--r-- | examples/example-enum-tag/src/main.rs | 10 |
2 files changed, 10 insertions, 8 deletions
diff --git a/examples/example-completion/src/main.rs b/examples/example-completion/src/main.rs index 7ca23b9..a34ccab 100644 --- a/examples/example-completion/src/main.rs +++ b/examples/example-completion/src/main.rs @@ -52,13 +52,13 @@ fn main() { program.with_dispatcher(CMDGreet); // --------- IMPORTANT --------- - // The `comp` feature makes `gen_program!()` generate a CompletionDispatcher automatically + // 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::CompletionDispatcher); + program.with_dispatcher(crate::CMDCompletion); // --------- IMPORTANT --------- // TIP: Note that the completion script reads stdout, - // so make sure no output is produced before the CompletionDispatcher is dispatched. + // so make sure no output is produced before the CMDCompletion is dispatched. program.exec_and_exit(); } @@ -109,7 +109,7 @@ pack!(ResultName = (u8, String)); #[chain] fn handle_greet(args: EntryGreet) -> Next { let result: ResultName = args - .pick(["-r", "--repeat"]) + .pick_or(["-r", "--repeat"], 1) .pick_or((), "World") .unpack() .into(); diff --git a/examples/example-enum-tag/src/main.rs b/examples/example-enum-tag/src/main.rs index 05419f7..30439f5 100644 --- a/examples/example-enum-tag/src/main.rs +++ b/examples/example-enum-tag/src/main.rs @@ -16,8 +16,8 @@ //! ``` use mingling::{ - EnumTag, Groupped, ShellContext, Suggest, macros::suggest_enum, parser::PickableEnum, - prelude::*, + macros::suggest_enum, parser::PickableEnum, prelude::*, EnumTag, Groupped, ShellContext, + Suggest, }; // Define the enum and derive the EnumTag trait @@ -56,7 +56,9 @@ pub enum ProgrammingLanguages { #[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")] + #[enum_desc( + "An object-oriented scripting language, famous for its concise and elegant syntax" + )] Ruby, #[default] @@ -96,7 +98,7 @@ gen_program!(); fn main() { let mut program = ThisProgram::new(); - program.with_dispatcher(CompletionDispatcher); + program.with_dispatcher(CMDCompletion); program.with_dispatcher(CMDLanguageSelection); program.exec_and_exit(); } |
