1
use std::process;
2

            
3
#[cfg(test)]
4
mod test;
5

            
6
pub const NAME: &str = env!("CARGO_PKG_NAME");
7
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
8
pub const COMMIT: Option<&str> = option_env!("CI_COMMIT_SHA");
9

            
10
1
fn version_information() -> String {
11
1
    let mut info = format!("{NAME}:\n    Version: v{VERSION}\n");
12
1
    let mut commit = COMMIT.unwrap_or("unknown");
13
1
    if commit.len() > 7 {
14
        commit = &commit[..7];
15
1
    }
16
1
    info.push_str(&format!("    Commit: {commit}"));
17

            
18
1
    info
19
1
}
20

            
21
pub fn print_version_and_exit() {
22
    println!("{}", version_information());
23
    process::exit(0);
24
}