Skip to content

Commit 5148a6d

Browse files
committed
Allow for -v/--verbose
1 parent 71c8de2 commit 5148a6d

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

src/main.rs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ mod env;
22
mod robot;
33

44
use clap::{Parser, Subcommand};
5-
use log::debug;
5+
use log::{LevelFilter, debug};
66
use std::fs::File;
77
use std::io::Write;
88
use std::path::PathBuf;
@@ -11,6 +11,9 @@ use std::path::PathBuf;
1111
#[command(version)]
1212
/// Checkmk synthetic monitoring command-line tool
1313
struct Cli {
14+
#[arg(short, long)]
15+
verbose: bool,
16+
1417
#[command(subcommand)]
1518
command: Command,
1619
}
@@ -27,9 +30,20 @@ enum Command {
2730
}
2831

2932
fn main() {
30-
env_logger::init();
31-
let _ = create_mambarc();
3233
let cli = Cli::parse();
34+
35+
// Set up logging
36+
let default_verbosity = if cli.verbose {
37+
LevelFilter::Debug
38+
} else {
39+
LevelFilter::Error
40+
};
41+
let mut env_logger_builder = env_logger::Builder::new();
42+
env_logger_builder.filter_level(default_verbosity);
43+
env_logger_builder.parse_default_env();
44+
env_logger_builder.init();
45+
46+
let _ = create_mambarc();
3347
match cli.command {
3448
Command::Env(sub) => env::run(sub),
3549
Command::Robot(sub) => robot::run(sub),
@@ -42,8 +56,8 @@ fn create_mambarc() -> std::io::Result<()> {
4256
changeps1: True
4357
4458
# proxy_servers:
45-
# http: http://user:pass@corp.com:8080_
46-
# https: https://user:pass@corp.com:8080_
59+
# http: http://user:pass@corp.com:8080
60+
# https: https://user:pass@corp.com:8080
4761
4862
# Use this only if you are behind a proxy that does SSL inspection
4963
# ssl_verify: false

0 commit comments

Comments
 (0)