summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/examples/http_bench.rs1
-rw-r--r--core/flags.rs43
2 files changed, 2 insertions, 42 deletions
diff --git a/core/examples/http_bench.rs b/core/examples/http_bench.rs
index 7cacf79b0..ea8058019 100644
--- a/core/examples/http_bench.rs
+++ b/core/examples/http_bench.rs
@@ -191,6 +191,7 @@ fn main() {
});
let args: Vec<String> = env::args().collect();
+ // NOTE: `--help` arg will display V8 help and exit
let args = deno::v8_set_flags(args);
log::set_logger(&LOGGER).unwrap();
diff --git a/core/flags.rs b/core/flags.rs
index 2da35734d..4deca6e2d 100644
--- a/core/flags.rs
+++ b/core/flags.rs
@@ -5,17 +5,13 @@ use libc::c_char;
use libc::c_int;
use std::ffi::CStr;
use std::ffi::CString;
-use std::mem;
use std::vec::Vec;
/// Pass the command line arguments to v8.
/// Returns a vector of command line arguments that V8 did not understand.
-/// Translates --v8-options into a --help flag for V8.
pub fn v8_set_flags(args: Vec<String>) -> Vec<String> {
// deno_set_v8_flags(int* argc, char** argv) mutates argc and argv to remove
// flags that v8 understands.
- // First parse core args, then convert to a vector of C strings.
- let (args, rest) = v8_set_flags_preprocess(args);
// Make a new array, that can be modified by V8::SetFlagsFromCommandLine(),
// containing mutable raw pointers to the individual command line args.
@@ -43,42 +39,5 @@ pub fn v8_set_flags(args: Vec<String>) -> Vec<String> {
let cstr = CStr::from_ptr(*ptr as *const c_char);
let slice = cstr.to_str().unwrap();
slice.to_string()
- }).chain(rest.into_iter())
- .collect()
-}
-
-// Returns args passed to V8, followed by args passed to JS
-fn v8_set_flags_preprocess(args: Vec<String>) -> (Vec<String>, Vec<String>) {
- let (rest, mut v8_args) =
- args.into_iter().partition(|ref a| a.as_str() == "--help");
-
- // Replace args being sent to V8
- for a in &mut v8_args {
- if a == "--v8-options" {
- mem::swap(a, &mut String::from("--help"));
- }
- }
- (v8_args, rest)
-}
-
-#[test]
-fn test_v8_set_flags_preprocess_1() {
- let js_args = v8_set_flags_preprocess(vec![
- "deno".to_string(),
- "--v8-options".to_string(),
- ]);
- assert_eq!(
- js_args,
- (vec!["deno".to_string(), "--help".to_string()], vec![])
- );
-}
-
-#[test]
-fn test_v8_set_flags_preprocess_2() {
- let js_args =
- v8_set_flags_preprocess(vec!["deno".to_string(), "--help".to_string()]);
- assert_eq!(
- js_args,
- (vec!["deno".to_string()], vec!["--help".to_string()])
- );
+ }).collect()
}