diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-08-03 20:30:33 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-08-03 20:38:02 +0800 |
| commit | fc0df246c2f55985de1813a9c30eb0c6e61c8a99 (patch) | |
| tree | 122187b5013b0021ca86fd830e5c170424dcab01 /mingling_cli/src/main.rs | |
| parent | f7862affd74ac3b129f9e9791a4cd4e1c7e3e6d1 (diff) | |
feat(cli): add dynamic completion scripts and global helpwip/mingling-cli-ux
Enable the dispatch_tree and comp features to generate
completion scripts during build and register global help
and completion support in the main entry point.
Diffstat (limited to 'mingling_cli/src/main.rs')
| -rw-r--r-- | mingling_cli/src/main.rs | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/mingling_cli/src/main.rs b/mingling_cli/src/main.rs index c822a12..149093c 100644 --- a/mingling_cli/src/main.rs +++ b/mingling_cli/src/main.rs @@ -1,6 +1,8 @@ -use crate::{linter::MinglingLinterSetup, metadata::MinglingMetadataSetup}; +use crate::metadata::MinglingMetadataSetup; use mingling::{ - macros::gen_program, + ShellContext, Suggest, + consts::HELP_FLAG, + macros::{completion, gen_program, help, suggest}, setup::{ExitCodeSetup, picker::HelpFlagSetup}, }; @@ -20,10 +22,21 @@ async fn main() { program.with_setup(ExitCodeSetup::default()); program.with_setup(MinglingMetadataSetup); - program.with_setup(MinglingLinterSetup); // Exec program.exec_and_exit().await; } +#[help] +pub fn help_global(_: EntryFallback) -> String { + include_str!("../help/help.txt").to_string() +} + +#[completion(EntryFallback)] +pub fn complete_global(_ctx: &ShellContext) -> Suggest { + suggest! { + HELP_FLAG: "Show help messages" + } +} + gen_program!(); |
