diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-04-17 00:55:09 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-04-17 00:55:09 +0800 |
| commit | 30f8f7749e63b710af8a15c88bf87ad71c004b26 (patch) | |
| tree | f587518f63933ad67ed2e09431fda5638fe46d59 /src/cli.rs | |
| parent | 2374370f8ea5e2c794e4838c12ed9f799e6206c8 (diff) | |
Add help and version flags with external files
Diffstat (limited to 'src/cli.rs')
| -rw-r--r-- | src/cli.rs | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -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); |
