提交 7a17e2ae 编写于 作者: A Andy Hayden 提交者: Ryan Dahl

Remove flags::process

It was doing two independent things:
- print help and exit
- set log level

It's better to do those explicitly in main.rs
上级 e1d5f82d
......@@ -2,11 +2,9 @@
use getopts::Options;
use libc::c_int;
use libdeno;
use log;
use std::ffi::CStr;
use std::ffi::CString;
use std::mem;
use std::process::exit;
use std::vec::Vec;
// Creates vector of strings, Vec<String>
......@@ -28,20 +26,6 @@ pub struct DenoFlags {
pub types_flag: bool,
}
pub fn process(flags: &DenoFlags, usage_string: &str) {
if flags.help {
println!("{}", &usage_string);
exit(0);
}
let log_level = if flags.log_debug {
log::LevelFilter::Debug
} else {
log::LevelFilter::Info
};
log::set_max_level(log_level);
}
pub fn get_usage(opts: &Options) -> String {
format!(
"Usage: deno script.ts {}
......
......@@ -81,8 +81,19 @@ fn main() {
eprintln!("{}", err);
std::process::exit(1)
});
if flags.help {
println!("{}", &usage_string);
std::process::exit(0);
}
log::set_max_level(if flags.log_debug {
log::LevelFilter::Debug
} else {
log::LevelFilter::Info
});
let mut isolate = isolate::Isolate::new(flags, rest_argv, ops::dispatch);
flags::process(&isolate.state.flags, &usage_string);
tokio_util::init(|| {
isolate
.execute("deno_main.js", "denoMain();")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册