|
@@ -12,6 +12,12 @@ use std::time::Duration;
|
|
|
|
|
|
mod cache;
|
|
|
|
|
|
+// Build-time information
|
|
|
+pub mod built_info {
|
|
|
+ // The file has been placed there by the build script.
|
|
|
+ include!(concat!(env!("OUT_DIR"), "/built.rs"));
|
|
|
+}
|
|
|
+
|
|
|
#[derive(Parser)]
|
|
|
#[command(
|
|
|
about = "Go Updater",
|
|
@@ -38,6 +44,8 @@ enum Commands {
|
|
|
Update {},
|
|
|
/// Display information
|
|
|
Info {},
|
|
|
+ /// Version
|
|
|
+ Version {},
|
|
|
}
|
|
|
|
|
|
/// Query `go env`
|
|
@@ -427,6 +435,33 @@ fn main() -> Result<()> {
|
|
|
println!("go os {}", go_os);
|
|
|
println!("go os arch: {}", go_os_arch);
|
|
|
}
|
|
|
+ Some(Commands::Version {}) => {
|
|
|
+ println!(
|
|
|
+ "This is version {}, built for {} by {}.\n",
|
|
|
+ built_info::PKG_VERSION,
|
|
|
+ built_info::TARGET,
|
|
|
+ built_info::RUSTC_VERSION
|
|
|
+ );
|
|
|
+
|
|
|
+ if let (Some(v), Some(dirty), Some(hash), Some(_short_hash)) = (
|
|
|
+ built_info::GIT_VERSION,
|
|
|
+ built_info::GIT_DIRTY,
|
|
|
+ built_info::GIT_COMMIT_HASH,
|
|
|
+ built_info::GIT_COMMIT_HASH_SHORT,
|
|
|
+ ) {
|
|
|
+ print!(
|
|
|
+ "I was built from git `{}`, commit {}.\nThe working directory was \"{}\".",
|
|
|
+ v,
|
|
|
+ hash,
|
|
|
+ if dirty { "dirty" } else { "clean" }
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ match built_info::GIT_HEAD_REF {
|
|
|
+ Some(r) => println!(" The branch was `{r}`.\n"),
|
|
|
+ None => println!("\n"),
|
|
|
+ }
|
|
|
+ }
|
|
|
None => {
|
|
|
// Display help.
|
|
|
let _show_help: Cli = Cli::parse_from(["", "--help"]);
|