Skip to content

Commit

Permalink
feat(cli): use --verbose to increase log level
Browse files Browse the repository at this point in the history
  • Loading branch information
loichyan committed Mar 28, 2023
1 parent db26b09 commit 4830e37
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ pub struct Cli {
/// Path(s) to load the icons cheat sheet or cached content.
#[arg(short, long, value_name(V_PATH))]
pub input: Vec<PathBuf>,
#[arg(short, long, action = clap::ArgAction::Count)]
pub verbose: u8,
#[command(subcommand)]
pub cmd: Command,
}
Expand Down
13 changes: 10 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,25 @@ use cli::Command;
use prompt::YesOrNo;
use runtime::{CheckerContext, Runtime};
use thisctx::WithContext;
use tracing::error;
use tracing::{error, Level};

static CACHED: &str = include_str!("./cached.txt");

fn main_impl() -> error::Result<()> {
let args = cli::Cli::parse();

let lv = match args.verbose {
0 => Level::WARN,
1 => Level::INFO,
2 => Level::DEBUG,
_ => Level::TRACE,
};
let subscriber = tracing_subscriber::FmtSubscriber::builder()
.with_max_level(tracing::Level::WARN)
.with_max_level(lv)
.without_time()
.finish();
tracing::subscriber::set_global_default(subscriber).context(error::Any)?;

let args = cli::Cli::parse();
let mut rt = Runtime::builder();
if args.input.is_empty() {
rt.load_cache(CACHED);
Expand Down

0 comments on commit 4830e37

Please sign in to comment.