feat: Support --verbose --version/-vV (#1182)

that provides more information:

```
cargo-binstall: 1.0.0
build-date: 2023-07-18
build-target: aarch64-apple-darwin
build-features: default,fancy_no_backtrace,git,rustls,static,trust_dns,zstd_thin
build-commit-hash: 39d8cfc07f2253080ce997e620406c2994dced25
build-commit-date: 2023-07-18
rustc-version: 1.71.0
rustc-commit-hash: 8ede3aae28fe6e4d52b38157d7bfe0d3bceef225
rustc-llvm-version: 16.0
```

Fixed #627

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2023-07-18 15:22:41 +10:00 committed by GitHub
parent c11261b88f
commit 0c5b7f115d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 95 additions and 8 deletions

View file

@ -318,6 +318,10 @@ pub struct Args {
#[clap(help_heading = "Meta", long, value_name = "LEVEL")]
pub log_level: Option<LevelFilter>,
/// Used with `--version` to print out verbose information.
#[clap(help_heading = "Meta", short, long, default_value_t = false)]
pub verbose: bool,
/// Equivalent to setting `log_level` to `off`.
///
/// This would override the `log_level`.

View file

@ -1,6 +1,6 @@
use std::time::Instant;
use binstalk::helpers::jobserver_client::LazyJobserverClient;
use binstalk::{helpers::jobserver_client::LazyJobserverClient, TARGET};
use log::LevelFilter;
use tracing::debug;
@ -22,7 +22,33 @@ fn main() -> MainExit {
let args = args::parse();
if args.version {
println!("{}", env!("CARGO_PKG_VERSION"));
let cargo_binstall_version = env!("CARGO_PKG_VERSION");
if args.verbose {
let build_date = env!("VERGEN_BUILD_DATE");
let features = env!("VERGEN_CARGO_FEATURES");
let git_sha = option_env!("VERGEN_GIT_SHA").unwrap_or("UNKNOWN");
let git_commit_date = option_env!("VERGEN_GIT_COMMIT_DATE").unwrap_or("UNKNOWN");
let rustc_semver = env!("VERGEN_RUSTC_SEMVER");
let rustc_commit_hash = env!("VERGEN_RUSTC_COMMIT_HASH");
let rustc_llvm_version = env!("VERGEN_RUSTC_LLVM_VERSION");
println!(
r#"cargo-binstall: {cargo_binstall_version}
build-date: {build_date}
build-target: {TARGET}
build-features: {features}
build-commit-hash: {git_sha}
build-commit-date: {git_commit_date}
rustc-version: {rustc_semver}
rustc-commit-hash: {rustc_commit_hash}
rustc-llvm-version: {rustc_llvm_version}"#
);
} else {
println!("{cargo_binstall_version}");
}
MainExit::Success(None)
} else {
logging(