From 81528b273c18693ebd3f05c6f8057ff8e632f4a0 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sun, 7 Jun 2026 02:25:27 +0800 Subject: Refactor mling to use new program architecture and install scripts --- mling/src/cli.rs | 77 -------------------------------------------------------- 1 file changed, 77 deletions(-) delete mode 100644 mling/src/cli.rs (limited to 'mling/src/cli.rs') diff --git a/mling/src/cli.rs b/mling/src/cli.rs deleted file mode 100644 index b628021..0000000 --- a/mling/src/cli.rs +++ /dev/null @@ -1,77 +0,0 @@ -use mingling::{ - macros::{r_println, renderer}, - setup::{BasicProgramSetup, GeneralRendererSetup}, -}; - -use crate::{CMDCompletion, ErrorDispatcherNotFound, ThisProgram, display::markdown}; - -pub mod list; -pub use list::*; - -pub mod namespace_mgr; -pub use namespace_mgr::*; - -pub mod read; -pub use read::*; - -pub mod install; -pub use install::*; - -/// Entry point for the CLI application. -/// -/// # Panics -/// -/// Panics on Windows if the virtual terminal processing cannot be enabled. -pub fn cli_entry() { - let mut program = ThisProgram::new(); - - // Plugins - program.with_setup(BasicProgramSetup); - program.with_setup(GeneralRendererSetup); - program.with_dispatcher(CMDCompletion); - - if program.pick_global_flag(["-v", "--version"]) { - println!("{}", include_str!("../res/version.txt").trim_end()); - return; - } - - // Help - if program.user_context.help { - println!( - "{}", - markdown(include_str!("../res/help-mling.txt").trim_end()) - ); - return; - } - - // Context query commands - program.with_dispatcher(ListInstalledCommand); - program.with_dispatchers(( - ReadTargetDirCommand, - ReadWorkspaceRootCommand, - ReadBinariesCommand, - )); - - // Namespace manage commands - program.with_dispatchers(( - TrustNamespaceCommand, - UntrustNamespaceCommand, - SetTrustNamespaceCommand, - RemoveNamespaceCommand, - )); - - // Install binaries command - program.with_dispatcher(InstallCommand); - - // Colored Setup - #[cfg(windows)] - colored::control::set_virtual_terminal(true).unwrap(); - - let _ = program.exec(); -} - -#[renderer] -pub(crate) fn fallback_disp(prev: ErrorDispatcherNotFound) { - r_println!("Error: command \"{}\" not found!", prev.join(" ")); - r_println!("Use \"mling --help\" for more information."); -} -- cgit