diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 3 | ||||
-rw-r--r-- | src/permissions.rs | 20 |
2 files changed, 11 insertions, 12 deletions
diff --git a/src/main.rs b/src/main.rs index 36a39dbf0..175464e31 100644 --- a/src/main.rs +++ b/src/main.rs @@ -61,6 +61,9 @@ fn print_err_and_exit(err: errors::RustOrJsError) { } fn main() { + #[cfg(windows)] + ansi_term::enable_ansi_support().ok(); // For Windows 10 + log::set_logger(&LOGGER).unwrap(); let args = env::args().collect(); let (mut flags, mut rest_argv, usage_string) = flags::set_flags(args) diff --git a/src/permissions.rs b/src/permissions.rs index fc14bea76..c05ea4ee5 100644 --- a/src/permissions.rs +++ b/src/permissions.rs @@ -3,6 +3,7 @@ use atty; use crate::flags::DenoFlags; +use ansi_term::Style; use crate::errors::permission_denied; use crate::errors::DenoResult; use std::io; @@ -32,7 +33,7 @@ impl DenoPermissions { return Ok(()); }; // TODO get location (where access occurred) - let r = permission_prompt("Deno requests access to run a subprocess."); + let r = permission_prompt("access to run a subprocess"); if r.is_ok() { self.allow_run.store(true, Ordering::SeqCst); } @@ -44,10 +45,7 @@ impl DenoPermissions { return Ok(()); }; // TODO get location (where access occurred) - let r = permission_prompt(&format!( - "Deno requests write access to \"{}\".", - filename - ));; + let r = permission_prompt(&format!("write access to \"{}\"", filename));; if r.is_ok() { self.allow_write.store(true, Ordering::SeqCst); } @@ -59,10 +57,8 @@ impl DenoPermissions { return Ok(()); }; // TODO get location (where access occurred) - let r = permission_prompt(&format!( - "Deno requests network access to \"{}\".", - domain_name - )); + let r = + permission_prompt(&format!("network access to \"{}\"", domain_name)); if r.is_ok() { self.allow_net.store(true, Ordering::SeqCst); } @@ -74,8 +70,7 @@ impl DenoPermissions { return Ok(()); }; // TODO get location (where access occurred) - let r = - permission_prompt(&"Deno requests access to environment variables."); + let r = permission_prompt(&"access to environment variables"); if r.is_ok() { self.allow_env.store(true, Ordering::SeqCst); } @@ -87,8 +82,9 @@ fn permission_prompt(message: &str) -> DenoResult<()> { if !atty::is(atty::Stream::Stdin) || !atty::is(atty::Stream::Stderr) { return Err(permission_denied()); }; + let msg = format!("⚠️ Deno requests {}. Grant? [yN] ", message); // print to stderr so that if deno is > to a file this is still displayed. - eprint!("{} Grant? [yN] ", message); + eprint!("{}", Style::new().bold().paint(msg)); let mut input = String::new(); let stdin = io::stdin(); let _nread = stdin.read_line(&mut input)?; |