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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
mod cache;
pub mod commands;
pub mod constants;
mod dir_monitor;
mod download;
mod os;
pub mod shim;
mod toolchain;
pub mod utils;
pub use anyhow::Result;
pub use structopt::StructOpt;
pub use thiserror::Error;
use git_testament::{git_testament, render_testament};
use lazy_static::lazy_static;
git_testament!(GIT_TESTAMENT);
fn git_version() -> &'static str {
lazy_static! {
static ref RENDERED: String = render_testament!(GIT_TESTAMENT);
}
&RENDERED
}
#[derive(StructOpt, Debug)]
#[structopt(version = git_version())]
pub struct Opt {
#[structopt(short, long, parse(from_occurrences))]
pub verbose: u8,
#[structopt(subcommand)]
pub subcommand: Option<commands::Command>,
}
#[cfg(test)]
pub mod tests {
use std::env;
#[test]
#[ignore]
fn version() {
let crate_version = structopt::clap::crate_version!();
let (v, git_version_without_v) = crate::git_version().split_at(1);
println!("crate_version: {:?}", crate_version);
println!("v: {}", v);
println!("git_version_without_v: {}", git_version_without_v);
assert_eq!(v, "v");
assert!(git_version_without_v.starts_with(crate_version));
}
}