1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
include!(concat!(env!("OUT_DIR"), "/version.rs"));

/// Generate version information.
pub fn version(verbose: bool, colorize: bool) -> String {
    match (verbose, colorize) {
        (true, true) => {
            format!("\x1b[32;1mml {}\x1b[0m ({} {}) (built {})\ncommit-hash: {}\ncommit-date: \
                     {}\nbuild-date: {}\nhost: {}\nrelease: {}\n",
                    semver(),
                    short_sha(),
                    commit_date(),
                    short_now(),
                    sha(),
                    commit_date(),
                    short_now(),
                    target(),
                    semver())
        }
        (true, false) => {
            format!("ml {} ({} {}) (built {})\ncommit-hash: {}\ncommit-date: {}\nbuild-date: \
                     {}\nhost: {}\nrelease: {}\n",
                    semver(),
                    short_sha(),
                    commit_date(),
                    short_now(),
                    sha(),
                    commit_date(),
                    short_now(),
                    target(),
                    semver())
        }
        (false, true) => {
            format!("\x1b[32;1mml {}\x1b[0m ({} {}) (built {})\n",
                    semver(),
                    short_sha(),
                    commit_date(),
                    short_now())
        }
        (false, false) => {
            format!("rh {} ({} {}) (built {})\n",
                    semver(),
                    short_sha(),
                    commit_date(),
                    short_now())
        }
    }
}