@@ -2,6 +2,21 @@ use clap::{crate_name, crate_version, App as ClapApp, AppSettings, Arg, ArgGroup
22use std::env;
33use std::path::Path;
44
5+lazy_static::lazy_static! {
6+ static ref VERSION: String = {
7+ #[cfg(feature = "bugreport")]
8+ let git_version = bugreport::git_version!(fallback = "");
9+ #[cfg(not(feature = "bugreport"))]
10+ let git_version = "";
11+
12+ if git_version.is_empty() {
13+ crate_version!().to_string()
14+ } else {
15+ format!("{} ({})", crate_version!(), git_version)
16+ }
17+ };
18+}
19+
520pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
621 let clap_color_setting = if interactive_output && env::var_os("NO_COLOR").is_none() {
722 AppSettings::ColoredHelp
@@ -10,7 +25,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
1025 };
1126
1227 let mut app = ClapApp::new(crate_name!())
13− .version(crate_version!())
28+ .version(VERSION.as_str())
1429 .global_setting(clap_color_setting)
1530 .global_setting(AppSettings::DeriveDisplayOrder)
1631 .global_setting(AppSettings::UnifiedHelpMessage)