2019-05-10 18:59:12 +02:00
|
|
|
#![feature(crate_visibility_modifier)]
|
|
|
|
#![feature(in_band_lifetimes)]
|
2019-05-23 09:23:06 +02:00
|
|
|
#![feature(async_await)]
|
2019-05-24 06:34:43 +02:00
|
|
|
#![feature(try_trait)]
|
2019-05-24 09:29:16 +02:00
|
|
|
#![feature(bind_by_move_pattern_guards)]
|
2019-05-10 18:59:12 +02:00
|
|
|
|
2019-05-23 06:30:43 +02:00
|
|
|
mod cli;
|
2019-05-10 18:59:12 +02:00
|
|
|
mod commands;
|
2019-05-15 18:12:38 +02:00
|
|
|
mod context;
|
2019-05-10 18:59:12 +02:00
|
|
|
mod env;
|
|
|
|
mod errors;
|
2019-05-28 08:45:18 +02:00
|
|
|
mod evaluate;
|
2019-05-10 18:59:12 +02:00
|
|
|
mod format;
|
|
|
|
mod object;
|
2019-05-11 06:45:57 +02:00
|
|
|
mod parser;
|
2019-05-13 19:30:51 +02:00
|
|
|
mod prelude;
|
2019-05-16 23:43:36 +02:00
|
|
|
mod shell;
|
2019-05-23 06:30:43 +02:00
|
|
|
mod stream;
|
2019-05-10 18:59:12 +02:00
|
|
|
|
2019-06-01 19:00:42 +02:00
|
|
|
use clap::{App, Arg};
|
|
|
|
use log::LevelFilter;
|
2019-05-10 18:59:12 +02:00
|
|
|
use std::error::Error;
|
|
|
|
|
|
|
|
fn main() -> Result<(), Box<Error>> {
|
2019-06-01 19:00:42 +02:00
|
|
|
let matches = App::new("nu shell")
|
|
|
|
.version("0.5")
|
|
|
|
.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 => {}
|
|
|
|
Some(values) => for item in values {
|
|
|
|
println!("filtering {:?}", item);
|
|
|
|
builder.filter_module(&format!("nu::{}", item), LevelFilter::Trace);
|
|
|
|
} //println!("{:?}", values.collect::<Vec<&str>>()),
|
|
|
|
}
|
|
|
|
|
|
|
|
builder.try_init()?;
|
|
|
|
|
|
|
|
// pretty_env_logger::init();
|
2019-05-24 06:34:43 +02:00
|
|
|
futures::executor::block_on(crate::cli::cli())?;
|
2019-05-23 09:23:06 +02:00
|
|
|
Ok(())
|
2019-05-15 18:12:38 +02:00
|
|
|
}
|