Crates.io | clap-log-flag |
lib.rs | clap-log-flag |
version | 0.2.1 |
source | src |
created_at | 2018-08-06 10:49:28.657946 |
updated_at | 2018-08-22 07:37:17.14695 |
description | Add a logger to CLIs using structopt |
homepage | |
repository | https://github.com/rust-clique/clap-log-flag |
max_upload_size | |
id | 77737 |
size | 28,137 |
Add a logger to CLIs using structopt.
extern crate clap_log_flag;
#[macro_use]
extern crate log;
extern crate clap_verbosity_flag;
#[macro_use]
extern crate structopt;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
struct Cli {
#[structopt(flatten)]
verbose: clap_verbosity_flag::Verbosity,
#[structopt(flatten)]
log: clap_log_flag::Log,
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let args = Cli::from_args();
args.log.log_all(args.verbose.log_level())?;
info!("hello");
error!("oh no!");
Ok(())
}
clap-log-flag 0.1.0
Yoshua Wuyts <yoshuawuyts@gmail.com>
Add a logger to CLIs using structopt
USAGE:
main [FLAGS]
FLAGS:
-h, --help Prints help information
-P, --pretty Enable pretty printing.
-V, --version Prints version information
-v, --verbosity Pass many times for more log output
$ cargo add clap-log-flag
MIT OR Apache-2.0