Skip to content

Commit

Permalink
Changed command flag -v to show version and exit. Selection of othe…
Browse files Browse the repository at this point in the history
…r log levels will be possible in config in the future.
  • Loading branch information
Revertron committed Apr 17, 2021
1 parent bd76b71 commit 75125b9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "alfis"
version = "0.4.8"
version = "0.4.9"
authors = ["Revertron <[email protected]>"]
edition = "2018"
build = "build.rs"
Expand Down
14 changes: 8 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand All @@ -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") {
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 75125b9

Please sign in to comment.