summaryrefslogtreecommitdiff
path: root/src/flags.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/flags.rs')
-rw-r--r--src/flags.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/flags.rs b/src/flags.rs
index d68bb5e09..a680c8aa1 100644
--- a/src/flags.rs
+++ b/src/flags.rs
@@ -23,6 +23,7 @@ pub struct DenoFlags {
pub version: bool,
pub reload: bool,
pub recompile: bool,
+ pub allow_read: bool,
pub allow_write: bool,
pub allow_net: bool,
pub allow_env: bool,
@@ -89,6 +90,9 @@ fn set_recognized_flags(
if matches.opt_present("recompile") {
flags.recompile = true;
}
+ if matches.opt_present("allow-read") {
+ flags.allow_read = true;
+ }
if matches.opt_present("allow-write") {
flags.allow_write = true;
}
@@ -102,9 +106,11 @@ fn set_recognized_flags(
flags.allow_run = true;
}
if matches.opt_present("allow-all") {
+ flags.allow_read = true;
flags.allow_env = true;
flags.allow_net = true;
flags.allow_run = true;
+ flags.allow_read = true;
flags.allow_write = true;
}
if matches.opt_present("types") {
@@ -142,6 +148,7 @@ pub fn set_flags(
// TODO(kevinkassimo): v8_set_flags intercepts '-help' with single '-'
// Resolve that and then uncomment line below (enabling Go style -long-flag)
// opts.long_only(true);
+ opts.optflag("", "allow-read", "Allow file system read access.");
opts.optflag("", "allow-write", "Allow file system write access.");
opts.optflag("", "allow-net", "Allow network access.");
opts.optflag("", "allow-env", "Allow environment access.");
@@ -262,12 +269,27 @@ fn test_set_flags_7() {
allow_net: true,
allow_env: true,
allow_run: true,
+ allow_read: true,
allow_write: true,
..DenoFlags::default()
}
)
}
+#[test]
+fn test_set_flags_8() {
+ let (flags, rest, _) =
+ set_flags(svec!["deno", "gist.ts", "--allow-read"]).unwrap();
+ assert_eq!(rest, svec!["deno", "gist.ts"]);
+ assert_eq!(
+ flags,
+ DenoFlags {
+ allow_read: true,
+ ..DenoFlags::default()
+ }
+ )
+}
+
// 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) =