diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-06-18 05:04:21 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-06-18 05:04:21 +0800 |
| commit | 961ee2eb342259398916dfe7458098f7c9297c11 (patch) | |
| tree | e8b3f2aa4cbd3afc8ce9da9751c4c0ad483f4273 /rola-cli/src/bin/rola.rs | |
| parent | 133ab48d0d9ac1d0f8ad87b7a71b8e6cd4f7d402 (diff) | |
feat: add build script for version info and shell completions
Introduce a build.rs that generates a version.txt file with the
package version, git commit hash, and date. Also generate shell
completion scripts using mingling's build utilities.
Migrate the `-v/--version` flag to read from the generated
version.txt and replace BasicProgramSetup with HelpFlagSetup.
Diffstat (limited to 'rola-cli/src/bin/rola.rs')
| -rw-r--r-- | rola-cli/src/bin/rola.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/rola-cli/src/bin/rola.rs b/rola-cli/src/bin/rola.rs index 1ebc3ae..0cfe675 100644 --- a/rola-cli/src/bin/rola.rs +++ b/rola-cli/src/bin/rola.rs @@ -3,19 +3,13 @@ use std::{env::current_dir, process::exit}; use mingling::{ Program, macros::program_setup, - setup::{BasicProgramSetup, ExitCodeSetup, QuietFlagSetup}, + setup::{ExitCodeSetup, HelpFlagSetup, QuietFlagSetup}, }; use rola_cli::{ThisProgram, locale, res::current_dir::ResCurrentDir}; fn main() { let mut program = ThisProgram::new(); - program.global_flag(["-v", "--version"], |_| { - let help = locale::helps::Basic::help().trim(); - eprintln!("{}", help); - exit(0) - }); - // Language locale::set_lang( program @@ -23,14 +17,20 @@ fn main() { .unwrap_or(locale::current_locales()), ); + // Version + program.global_flag(["-v", "--version"], |_| { + eprintln!("{}", include_str!("../../version.txt")); + exit(0) + }); + // Resources program.with_resource(ResCurrentDir { cwd: current_dir().unwrap(), }); // Setup + program.with_setup(HelpFlagSetup::new(["-h", "--help"])); program.with_setup(StandardOutputSetup); - program.with_setup(BasicProgramSetup); program.with_setup(ExitCodeSetup::default()); // Execute |
