mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 09:31:22 -05:00
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
This commit is contained in:
parent
e1d5f82d36
commit
7a17e2aec6
2 changed files with 12 additions and 17 deletions
16
src/flags.rs
16
src/flags.rs
|
@ -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 {}
|
||||
|
|
13
src/main.rs
13
src/main.rs
|
@ -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();")
|
||||
|
|
Loading…
Add table
Reference in a new issue