From 5731d71b070eb9a2b103a891fa47655420d74afd Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Fri, 28 May 2021 22:37:07 +1000 Subject: [PATCH] Implement version number --- Cargo.lock | 29 +++++++++++++++++++++++++++++ Cargo.toml | 1 + src/main.rs | 5 +++++ 3 files changed, 35 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index ac57375..40d2b6f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -47,6 +47,28 @@ dependencies = [ "syn", ] +[[package]] +name = "git-version" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94918e83f1e01dedc2e361d00ce9487b14c58c7f40bab148026fa39d42cb41e2" +dependencies = [ + "git-version-macro", + "proc-macro-hack", +] + +[[package]] +name = "git-version-macro" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34a97a52fdee1870a34fa6e4b77570cba531b27d1838874fef4429a791a3d657" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "gmp-mpfr-sys" version = "1.4.5" @@ -108,6 +130,7 @@ name = "opentally" version = "0.1.0" dependencies = [ "clap", + "git-version", "num-traits", "rug", ] @@ -142,6 +165,12 @@ dependencies = [ "version_check", ] +[[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.27" diff --git a/Cargo.toml b/Cargo.toml index 571e2dc..1f13b0f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ authors = ["Lee Yingtong Li "] edition = "2018" [dependencies] +git-version = "0.3.4" num-traits = "0.2" [dependencies.rug] diff --git a/src/main.rs b/src/main.rs index ea73a82..0feedc5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,11 +23,16 @@ use crate::election::{CandidateState, CountState, CountStateOrRef, Election, Sta use crate::numbers::{Number, NumType}; use clap::Clap; +use git_version::git_version; use std::fs::File; use std::io::{self, BufRead}; +const VERSION: &str = git_version!(args=["--always", "--dirty=-dev"], fallback="unknown"); + +/// Open-source election vote counting #[derive(Clap)] +#[clap(name="OpenTally", version=VERSION)] struct Opts { #[clap(subcommand)] command: Command,