diff options
author | Teddy Wing | 2020-08-03 20:00:01 +0200 |
---|---|---|
committer | Teddy Wing | 2020-08-03 20:00:01 +0200 |
commit | 2f983a7f1b973d72d0c0a43d5679161acf4c653c (patch) | |
tree | 28008eda0357cc0d88be1921095f9fcf70cb7507 /src | |
parent | e8510c5ca5c3f24cbb1d18adec020897f02d5818 (diff) | |
download | git-suggestion-2f983a7f1b973d72d0c0a43d5679161acf4c653c.tar.bz2 |
Config: Add a version argument
Allow getting the program version from the command line.
Diffstat (limited to 'src')
-rw-r--r-- | src/config.rs | 8 | ||||
-rw-r--r-- | src/lib.rs | 3 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs index 39a8158..f451ea5 100644 --- a/src/config.rs +++ b/src/config.rs @@ -6,6 +6,7 @@ use git2::{self, Repository}; use thiserror::Error; use crate::owner_repo::{self, OwnerRepo}; +use crate::VERSION; /// Program-specific prefix for Git config values. @@ -56,6 +57,7 @@ impl Config { "REMOTE", ); opts.optflag("h", "help", "print this help menu"); + opts.optflag("V", "version", "show the program version"); let opt_matches = opts.parse(&args[1..])?; @@ -65,6 +67,12 @@ impl Config { process::exit(exitcode::USAGE); } + if opt_matches.opt_present("V") { + println!("{}", VERSION); + + process::exit(exitcode::OK); + } + if opt_matches.free.is_empty() { print_usage(&opts, usage_brief); @@ -9,3 +9,6 @@ mod suggestion; pub use suggestion::for_suggestion; + + +const VERSION: &'static str = "0.1.0"; |