aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-04-17 00:55:09 +0800
committer魏曹先生 <1992414357@qq.com>2026-04-17 00:55:09 +0800
commit30f8f7749e63b710af8a15c88bf87ad71c004b26 (patch)
treef587518f63933ad67ed2e09431fda5638fe46d59 /src
parent2374370f8ea5e2c794e4838c12ed9f799e6206c8 (diff)
Add help and version flags with external files
Diffstat (limited to 'src')
-rw-r--r--src/cli.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/cli.rs b/src/cli.rs
index 71936cc..a62d41c 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -1,4 +1,4 @@
-use std::{fs::create_dir_all, io::ErrorKind, path::PathBuf};
+use std::{fs::create_dir_all, io::ErrorKind, path::PathBuf, process::exit};
use mingling::{
AnyOutput, Groupped, ShellContext, Suggest, SuggestItem,
@@ -21,6 +21,16 @@ use crate::{
pub async fn entry() {
let mut program = ThisProgram::new();
+ if program.pick_global_flag(["-v", "--version"]) {
+ println!("{}", include_str!("../version.txt").trim());
+ exit(0)
+ }
+
+ if program.pick_global_flag(["-h", "--help"]) {
+ println!("{}", include_str!("../help.txt").trim());
+ exit(0)
+ }
+
// Add Completion
program.with_dispatcher(CompletionDispatcher);