mirror of
https://github.com/watchexec/watchexec.git
synced 2024-09-28 22:21:33 +02:00
Emit log level separately from Args
This commit is contained in:
parent
757de0d92e
commit
31fd818247
16
src/cli.rs
16
src/cli.rs
@ -120,12 +120,12 @@ pub fn clear_screen() {
|
||||
}
|
||||
|
||||
#[deprecated(since = "1.15.0", note = "this will be removed from the library API. use the builder")]
|
||||
pub fn get_args() -> error::Result<Args> {
|
||||
pub fn get_args() -> error::Result<(Args, LevelFilter)> {
|
||||
get_args_impl(None::<&[&str]>)
|
||||
}
|
||||
|
||||
#[deprecated(since = "1.15.0", note = "this will be removed from the library API. use the builder")]
|
||||
pub fn get_args_from<I, T>(from: I) -> error::Result<Args>
|
||||
pub fn get_args_from<I, T>(from: I) -> error::Result<(Args, LevelFilter)>
|
||||
where
|
||||
I: IntoIterator<Item = T>,
|
||||
T: Into<OsString> + Clone,
|
||||
@ -133,7 +133,7 @@ where
|
||||
get_args_impl(Some(from))
|
||||
}
|
||||
|
||||
fn get_args_impl<I, T>(from: Option<I>) -> error::Result<Args>
|
||||
fn get_args_impl<I, T>(from: Option<I>) -> error::Result<(Args, LevelFilter)>
|
||||
where
|
||||
I: IntoIterator<Item = T>,
|
||||
T: Into<OsString> + Clone,
|
||||
@ -326,5 +326,13 @@ where
|
||||
config.once = true;
|
||||
}
|
||||
|
||||
Ok(config)
|
||||
let loglevel = if args.is_present("verbose") {
|
||||
LevelFilter::Debug
|
||||
} else if args.is_present("changes") {
|
||||
LevelFilter::Info
|
||||
} else {
|
||||
LevelFilter::Warn
|
||||
};
|
||||
|
||||
Ok((config, loglevel))
|
||||
}
|
||||
|
13
src/main.rs
13
src/main.rs
@ -5,16 +5,9 @@ extern crate watchexec;
|
||||
use watchexec::{cli, error, run};
|
||||
|
||||
fn main() -> error::Result<()> {
|
||||
let args = cli::get_args()?;
|
||||
|
||||
if args.debug {
|
||||
init_logger(log::LevelFilter::Debug);
|
||||
} else if args.changes {
|
||||
init_logger(log::LevelFilter::Info);
|
||||
} else {
|
||||
init_logger(log::LevelFilter::Warn);
|
||||
}
|
||||
|
||||
#[allow(deprecated)]
|
||||
let (args, loglevel) = cli::get_args()?;
|
||||
init_logger(loglevel);
|
||||
run(args)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user