From 7ca01e66c0d1c0e4406f47b694e843e373e092a3 Mon Sep 17 00:00:00 2001 From: Bart Noordervliet Date: Sun, 24 Apr 2022 22:29:57 +0200 Subject: [PATCH] Show version number when run without arguments Takes the version from `git describe --tags` --- Cargo.lock | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + src/main.rs | 6 ++++- 3 files changed, 70 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 41ec5a0..51351bc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,6 +23,28 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95765f67b4b18863968b4a1bd5bb576f732b29a4a28c7cd84c09fa3e2875f33c" +[[package]] +name = "git-version" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6b0decc02f4636b9ccad390dcbe77b722a77efedfa393caf8379a51d5c61899" +dependencies = [ + "git-version-macro", + "proc-macro-hack", +] + +[[package]] +name = "git-version-macro" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe69f1cbdb6e28af2bac214e943b99ce8a0a06b447d15d3e61161b0423139f3f" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -41,6 +63,21 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + +[[package]] +name = "proc-macro2" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1" +dependencies = [ + "unicode-xid", +] + [[package]] name = "quick-xml" version = "0.22.0" @@ -50,6 +87,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "quote" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" +dependencies = [ + "proc-macro2", +] + [[package]] name = "regex" version = "1.5.4" @@ -67,12 +113,30 @@ version = "0.6.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" +[[package]] +name = "syn" +version = "1.0.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b683b2b825c8eef438b77c36a06dc262294da3d5a5813fac20da149241dcd44d" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + [[package]] name = "xml-to-postgres" version = "1.2.0" dependencies = [ "cow-utils", "fast-float", + "git-version", "lazy_static", "quick-xml", "regex", diff --git a/Cargo.toml b/Cargo.toml index 0d8cc5d..1247a29 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,3 +13,4 @@ regex = "1" lazy_static = "1" cow-utils = "0.1" fast-float = "0.2" +git-version = "0.3" diff --git a/src/main.rs b/src/main.rs index fa51beb..5c144d7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,6 +13,7 @@ use yaml_rust::yaml::Yaml; use regex::Regex; use lazy_static::lazy_static; use cow_utils::CowUtils; +use git_version::git_describe; macro_rules! fatalerr { () => ({ @@ -470,7 +471,10 @@ fn main() { else if args.len() == 3 { bufread = Box::new(BufReader::new(File::open(&args[2]).unwrap_or_else(|err| fatalerr!("Error: failed to open input file '{}': {}", args[2], err)))); } - else { fatalerr!("Usage: {} [xmlfile]", args[0]); } + else { + eprintln!("xml-to-postgres {}", git_describe!("--tags")); + fatalerr!("Usage: {} [xmlfile]", args[0]); + } let config = { let mut config_str = String::new();