From a72209811fcee0e05e45562bc702b93388b52c30 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 3 Aug 2026 20:30:33 +0800 Subject: feat(cli): add dynamic completion scripts and global help 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. --- mingling_cli/src/main.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'mingling_cli/src/main.rs') 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!(); -- cgit