From 517082bbed049441a75666eb09b12cd8252a1edd Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Tue, 28 Apr 2026 18:00:27 +0800 Subject: Remove implicit help print and add version flag --- mling/res/guide.txt | 20 -------------------- mling/res/version.txt | 20 ++++++++++++++++++++ mling/src/cli.rs | 11 +++++------ 3 files changed, 25 insertions(+), 26 deletions(-) delete mode 100644 mling/res/guide.txt create mode 100644 mling/res/version.txt (limited to 'mling') diff --git a/mling/res/guide.txt b/mling/res/guide.txt deleted file mode 100644 index b1548c8..0000000 --- a/mling/res/guide.txt +++ /dev/null @@ -1,20 +0,0 @@ - █ - ███ - ██▒██ ┌────────────────────────────────────┐ - ██▒▒▒██ │ Mingling │ - ██▒ ▒██ │ USE: │ - ███▒ ▒███ │ Run command in your project │ - ███▒▒█████▒▒███ │ > cargo add mingling │ - █████▒ ████ ▒█████ │ ^^^^^^^^ │ - ██████▒▒ █▒ ██ ▒█ ▒███████ │ Or add this to your Cargo.toml │ - █████▒▒▒▒█▒ █▒ ██ ▒█ ▒██▒▒▒▒█████ │ > mingling = "0.1.7" │ - ▒▒▒▒▒ ██ ██ ▒██ ▒▒▒▒▒ └────────────────────────────────────┘ - ▒▒███████████████ ┌────────────────────────────────────┐ - ▒▒▒███▒▒▒▒▒▒▒▒ │ INSTALL TOOLS: │ - ████ │ Run command to install │ - ███▒▒ │ > cargo install mingling-cli │ - ████▒ │ ^^^^^^^^^^^^ │ - ▒▒▒█████ │ Then run command to use │ - ▒▒▒▒▒████ │ > mling --help │ - ▒▒▒█████ └────────────────────────────────────┘ - ▒▒▒▒▒ diff --git a/mling/res/version.txt b/mling/res/version.txt new file mode 100644 index 0000000..b1548c8 --- /dev/null +++ b/mling/res/version.txt @@ -0,0 +1,20 @@ + █ + ███ + ██▒██ ┌────────────────────────────────────┐ + ██▒▒▒██ │ Mingling │ + ██▒ ▒██ │ USE: │ + ███▒ ▒███ │ Run command in your project │ + ███▒▒█████▒▒███ │ > cargo add mingling │ + █████▒ ████ ▒█████ │ ^^^^^^^^ │ + ██████▒▒ █▒ ██ ▒█ ▒███████ │ Or add this to your Cargo.toml │ + █████▒▒▒▒█▒ █▒ ██ ▒█ ▒██▒▒▒▒█████ │ > mingling = "0.1.7" │ + ▒▒▒▒▒ ██ ██ ▒██ ▒▒▒▒▒ └────────────────────────────────────┘ + ▒▒███████████████ ┌────────────────────────────────────┐ + ▒▒▒███▒▒▒▒▒▒▒▒ │ INSTALL TOOLS: │ + ████ │ Run command to install │ + ███▒▒ │ > cargo install mingling-cli │ + ████▒ │ ^^^^^^^^^^^^ │ + ▒▒▒█████ │ Then run command to use │ + ▒▒▒▒▒████ │ > mling --help │ + ▒▒▒█████ └────────────────────────────────────┘ + ▒▒▒▒▒ diff --git a/mling/src/cli.rs b/mling/src/cli.rs index 65ba02a..465d813 100644 --- a/mling/src/cli.rs +++ b/mling/src/cli.rs @@ -20,12 +20,6 @@ pub mod install; pub use install::*; pub fn cli_entry() { - // Facade - if std::env::args().len() == 1 { - println!("{}", include_str!("../res/guide.txt").trim_end()); - return; - } - let mut program = ThisProgram::new(); // Plugins @@ -33,6 +27,11 @@ pub fn cli_entry() { program.with_setup(GeneralRendererSetup); program.with_dispatcher(CompletionDispatcher); + if program.pick_global_flag(["-v", "--version"]) { + println!("{}", include_str!("../res/version.txt").trim_end()); + return; + } + // Help if program.user_context.help { println!( -- cgit