summaryrefslogtreecommitdiff
path: root/cli/flags.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2019-07-31 17:02:20 +0200
committerRyan Dahl <ry@tinyclouds.org>2019-07-31 11:02:20 -0400
commite7cee29c849286f9b492eb404634a0387b9a75a0 (patch)
tree00d3541e8b17837381c23df880ab4a19887aaa19 /cli/flags.rs
parent421cbd39b4f0fdbdfc2eeed6da8dd3410246a044 (diff)
Add --current-thread flag (#2702)
Diffstat (limited to 'cli/flags.rs')
-rw-r--r--cli/flags.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/cli/flags.rs b/cli/flags.rs
index 978b0409f..194e254ec 100644
--- a/cli/flags.rs
+++ b/cli/flags.rs
@@ -43,6 +43,8 @@ pub struct DenoFlags {
pub v8_flags: Option<Vec<String>>,
pub xeval_replvar: Option<String>,
pub xeval_delim: Option<String>,
+ // Use tokio::runtime::current_thread
+ pub current_thread: bool,
}
static ENV_VARIABLES_HELP: &str = "ENVIRONMENT VARIABLES:
@@ -158,6 +160,12 @@ To get help on the another subcommands (run in this case):
.help("Load compiler configuration file")
.takes_value(true)
.global(true),
+ )
+ .arg(
+ Arg::with_name("current-thread")
+ .long("current-thread")
+ .global(true)
+ .help("Use tokio::runtime::current_thread"),
).arg(
Arg::with_name("importmap")
.long("importmap")
@@ -443,6 +451,9 @@ pub fn parse_flags(
) -> DenoFlags {
let mut flags = maybe_flags.unwrap_or_default();
+ if matches.is_present("current-thread") {
+ flags.current_thread = true;
+ }
if matches.is_present("log-level") {
flags.log_level = match matches.value_of("log-level").unwrap() {
"debug" => Some(Level::Debug),
@@ -1620,4 +1631,19 @@ mod tests {
assert_eq!(subcommand, DenoSubcommand::Run);
assert_eq!(argv, svec!["deno", "script.ts"])
}
+
+ #[test]
+ fn test_flags_from_vec_35() {
+ let (flags, subcommand, argv) =
+ flags_from_vec(svec!["deno", "--current-thread", "script.ts"]);
+ assert_eq!(
+ flags,
+ DenoFlags {
+ current_thread: true,
+ ..DenoFlags::default()
+ }
+ );
+ assert_eq!(subcommand, DenoSubcommand::Run);
+ assert_eq!(argv, svec!["deno", "script.ts"])
+ }
}