2019-06-01 17:00:42 +00:00
|
|
|
use clap::{App, Arg};
|
|
|
|
use log::LevelFilter;
|
2019-05-10 16:59:12 +00:00
|
|
|
use std::error::Error;
|
|
|
|
|
2019-06-03 03:48:58 +00:00
|
|
|
fn main() -> Result<(), Box<dyn Error>> {
|
2019-07-20 01:12:04 +00:00
|
|
|
let matches = App::new("nushell")
|
2019-08-24 15:25:04 +00:00
|
|
|
.version(clap::crate_version!())
|
2019-06-01 17:00:42 +00:00
|
|
|
.arg(
|
|
|
|
Arg::with_name("loglevel")
|
|
|
|
.short("l")
|
|
|
|
.long("loglevel")
|
|
|
|
.value_name("LEVEL")
|
|
|
|
.possible_values(&["error", "warn", "info", "debug", "trace"])
|
|
|
|
.takes_value(true),
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
Arg::with_name("develop")
|
|
|
|
.long("develop")
|
|
|
|
.multiple(true)
|
|
|
|
.takes_value(true),
|
|
|
|
)
|
|
|
|
.get_matches();
|
|
|
|
|
|
|
|
let loglevel = match matches.value_of("loglevel") {
|
|
|
|
None => LevelFilter::Warn,
|
|
|
|
Some("error") => LevelFilter::Error,
|
|
|
|
Some("warn") => LevelFilter::Warn,
|
|
|
|
Some("info") => LevelFilter::Info,
|
|
|
|
Some("debug") => LevelFilter::Debug,
|
|
|
|
Some("trace") => LevelFilter::Trace,
|
|
|
|
_ => unreachable!(),
|
|
|
|
};
|
|
|
|
|
|
|
|
let mut builder = pretty_env_logger::formatted_builder();
|
|
|
|
|
|
|
|
if let Ok(s) = std::env::var("RUST_LOG") {
|
|
|
|
builder.parse_filters(&s);
|
|
|
|
}
|
|
|
|
|
|
|
|
builder.filter_module("nu", loglevel);
|
|
|
|
|
|
|
|
match matches.values_of("develop") {
|
|
|
|
None => {}
|
2019-06-01 21:15:21 +00:00
|
|
|
Some(values) => {
|
|
|
|
for item in values {
|
|
|
|
builder.filter_module(&format!("nu::{}", item), LevelFilter::Trace);
|
|
|
|
}
|
|
|
|
}
|
2019-06-01 17:00:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
builder.try_init()?;
|
|
|
|
|
2019-06-27 04:56:48 +00:00
|
|
|
futures::executor::block_on(nu::cli())?;
|
2019-05-23 07:23:06 +00:00
|
|
|
Ok(())
|
2019-05-15 16:12:38 +00:00
|
|
|
}
|