diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-08-07 12:52:46 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-08-07 16:57:24 +0800 |
| commit | 32ee3596042cc4e723afd30b87298a13feef7c24 (patch) | |
| tree | 5d3bec726b5f93cc5a0e3f36ea76dd13ef2ec1ce /mingling_cli/src/bin/cli.rs | |
| parent | b5e88fe3b188bf5fa50d022714863f018550ed8b (diff) | |
chore: move CLI entry to bin and restructure imports
Move the CLI binary from `src/main.rs` to `src/bin/cli.rs`
and move shared program generation into a new lib.rs module.
Diffstat (limited to 'mingling_cli/src/bin/cli.rs')
| -rw-r--r-- | mingling_cli/src/bin/cli.rs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/mingling_cli/src/bin/cli.rs b/mingling_cli/src/bin/cli.rs new file mode 100644 index 0000000..28362e0 --- /dev/null +++ b/mingling_cli/src/bin/cli.rs @@ -0,0 +1,51 @@ +use mingling::{ + ShellContext, Suggest, + consts::HELP_FLAG, + macros::{completion, help, suggest}, + setup::{ExitCodeSetup, picker::HelpFlagSetup}, +}; +use mingling_cli::{ + EntryFallback, ThisProgram, + linter::registry::LintRegistrySetup, + metadata::{ + MinglingMetadataSetup, + setup::{ + ARG_ALL_FEATURES, ARG_FEATURES, ARG_MANIFEST_PATH, ARG_MESSAGE_FORMAT, + ARG_NO_DEFAULT_FEATURES, ARG_NO_DEPS, + }, + }, + utils::display::ColorCode, +}; + +#[tokio::main] +async fn main() { + let mut program = ThisProgram::new(); + + // Setups + program.with_setup(HelpFlagSetup::default()); + program.with_setup(ExitCodeSetup::default()); + + program.with_setup(MinglingMetadataSetup); + program.with_setup(LintRegistrySetup); + + // Exec + program.exec_and_exit().await; +} + +#[help] +pub fn help_global(_: EntryFallback) -> String { + include_str!("../../help/help.txt").parse_color_code() +} + +#[completion(EntryFallback)] +pub fn complete_global(_ctx: &ShellContext) -> Suggest { + suggest! { + HELP_FLAG: "Show help messages", + ARG_FEATURES.clone(): "List of features to enable", + ARG_MANIFEST_PATH.clone(): "Custom path to Cargo.toml", + ARG_MESSAGE_FORMAT.clone(): "Output message format", + ARG_ALL_FEATURES: "Enable all features", + ARG_NO_DEFAULT_FEATURES: "Disable default features", + ARG_NO_DEPS: "Do not include dependencies in metadata", + } +} |
