From 75125b971b3bb5dda5d2fdb3ea350037c5438fd8 Mon Sep 17 00:00:00 2001 From: Revertron Date: Sat, 17 Apr 2021 20:37:20 +0200 Subject: [PATCH] Changed command flag `-v` to show version and exit. Selection of other log levels will be possible in config in the future. --- Cargo.toml | 2 +- src/main.rs | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8c6096d..95028e6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "alfis" -version = "0.4.8" +version = "0.4.9" authors = ["Revertron "] edition = "2018" build = "build.rs" diff --git a/src/main.rs b/src/main.rs index 461ac1f..1957c85 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,7 +43,7 @@ fn main() { let mut opts = Options::new(); opts.optflag("h", "help", "Print this help menu"); opts.optflag("n", "nogui", "Run without graphic user interface (default for no gui builds)"); - opts.optflag("v", "verbose", "Show more debug messages"); + opts.optflag("v", "version", "Print version and exit"); opts.optflag("d", "debug", "Show trace messages, more than debug"); opts.optflag("b", "blocks", "List blocks from DB and exit"); opts.optflag("g", "generate", "Generate new config file. Generated config will be printed to console."); @@ -60,12 +60,17 @@ fn main() { if opt_matches.opt_present("h") { let brief = format!("Usage: {} [options]", program); println!("{}", opts.usage(&brief)); - return; + exit(0); + } + + if opt_matches.opt_present("v") { + println!("ALFIS v{}", env!("CARGO_PKG_VERSION")); + exit(0); } if opt_matches.opt_present("g") { println!("{}", include_str!("../alfis.toml")); - return; + exit(0); } match opt_matches.opt_str("u") { @@ -148,9 +153,6 @@ fn main() { /// Sets up logger in accordance with command line options fn setup_logger(opt_matches: &Matches) { let mut level = LevelFilter::Info; - if opt_matches.opt_present("v") { - level = LevelFilter::Debug; - } if opt_matches.opt_present("d") { level = LevelFilter::Trace; }