diff options
| author | 魏曹先生 <1992414357@qq.com> | 2025-11-04 14:29:34 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2025-11-04 14:29:34 +0800 |
| commit | 5991905ae9fb519a3a43c599c5515ba39c04e5fb (patch) | |
| tree | 3d9dcb37a30c9a17070c30c7964afec32a09435b /src/bin/jvv.rs | |
| parent | 57320aa7832d88c8e60fa0423df31cf71361ff58 (diff) | |
Add compile-time version and build information
- Add build script to generate compile_info.rs with build metadata -
Include version, build date, target platform, and toolchain info - Add
version command to both jv and jvv binaries - Update help documentation
with version information - Ignore generated compile_info.rs in git
Diffstat (limited to 'src/bin/jvv.rs')
| -rw-r--r-- | src/bin/jvv.rs | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/src/bin/jvv.rs b/src/bin/jvv.rs index 8480029..8dc9c88 100644 --- a/src/bin/jvv.rs +++ b/src/bin/jvv.rs @@ -16,8 +16,9 @@ use just_enough_vcs::{ }, }, }; -use just_enough_vcs_cli::utils::{ - build_env_logger::build_env_logger, lang_selector::current_locales, md_colored::md, +use just_enough_vcs_cli::{ + data::compile_info::CompileInfo, + utils::{build_env_logger::build_env_logger, lang_selector::current_locales, md_colored::md}, }; use log::{error, info}; use rust_i18n::{set_locale, t}; @@ -40,6 +41,10 @@ struct JustEnoughVcsVault { #[derive(Subcommand, Debug)] enum JustEnoughVcsVaultCommand { + /// Version information + #[command(alias = "--version", alias = "-v")] + Version(VersionArgs), + /// Get vault info in the current directory #[command(alias = "-H")] Here(HereArgs), @@ -65,6 +70,12 @@ enum JustEnoughVcsVaultCommand { ServiceListen(ListenArgs), } +#[derive(Parser, Debug)] +struct VersionArgs { + #[arg(short = 'C', long = "compile-info")] + compile_info: bool, +} + #[derive(Subcommand, Debug)] enum MemberManage { /// Register a member to the vault @@ -178,6 +189,27 @@ async fn main() { }; match parser.command { + JustEnoughVcsVaultCommand::Version(version_args) => { + let compile_info = CompileInfo::default(); + println!( + "{}", + md(t!("jvv.version.header", version = compile_info.cli_version)) + ); + + if version_args.compile_info { + println!( + "\n{}", + md(t!( + "jvv.version.compile_info", + build_time = compile_info.date, + build_target = compile_info.target, + build_platform = compile_info.platform, + build_toolchain = compile_info.toolchain + )) + ); + } + } + JustEnoughVcsVaultCommand::Here(here_args) => { if here_args.help { println!("{}", md(t!("jvv.here"))); |
