diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-01-19 20:46:10 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-01-19 20:46:10 +0400 |
| commit | 65e864965ec6e4a08a8e6696f779a5734033b6be (patch) | |
| tree | 3c1c35d7e4c6215d1a0d41b28f18fd53c9dff86a /src | |
| parent | 55ad36addc4576b78a1b22d09fc9d315aac0b101 (diff) | |
| download | niri-65e864965ec6e4a08a8e6696f779a5734033b6be.tar.gz niri-65e864965ec6e4a08a8e6696f779a5734033b6be.tar.bz2 niri-65e864965ec6e4a08a8e6696f779a5734033b6be.zip | |
Print git version in clap too
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.rs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs index af2346e7..78edd8ea 100644 --- a/src/main.rs +++ b/src/main.rs @@ -49,7 +49,7 @@ use crate::ipc::client::handle_msg; use crate::utils::{cause_panic, REMOVE_ENV_RUST_BACKTRACE, REMOVE_ENV_RUST_LIB_BACKTRACE}; #[derive(Parser)] -#[command(author, version, about, long_about = None)] +#[command(author, version = version(), about, long_about = None)] #[command(args_conflicts_with_subcommands = true)] #[command(subcommand_value_name = "SUBCOMMAND")] #[command(subcommand_help_heading = "Subcommands")] @@ -151,11 +151,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { } } - info!( - "starting version {} ({})", - env!("CARGO_PKG_VERSION"), - git_version!(fallback = "unknown commit"), - ); + info!("starting version {}", &version()); // Load the config. let path = cli.config.or_else(default_config_path); @@ -257,6 +253,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { Ok(()) } +fn version() -> String { + format!( + "{} ({})", + env!("CARGO_PKG_VERSION"), + git_version!(fallback = "unknown commit"), + ) +} + fn import_env_to_systemd() { let rv = Command::new("/bin/sh") .args([ |
