1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 15:24:46 -05:00

refactor(permissions): use less space for permissions prompt (#17708)

This commit is contained in:
Bartek Iwańczuk 2023-02-10 12:29:03 +01:00 committed by GitHub
parent b3e88e0681
commit 9ea899afa7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -199,16 +199,16 @@ impl PermissionPrompter for TtyPrompter {
// print to stderr so that if stdout is piped this is still displayed. // print to stderr so that if stdout is piped this is still displayed.
const OPTS: &str = "[y/n] (y = yes, allow; n = no, deny)"; const OPTS: &str = "[y/n] (y = yes, allow; n = no, deny)";
eprint!("{PERMISSION_EMOJI} "); eprint!("{PERMISSION_EMOJI} ");
eprint!("{}", colors::bold("Deno requests ")); eprint!("{}", colors::bold("Deno requests "));
eprint!("{}", colors::bold(message)); eprint!("{}", colors::bold(message));
eprintln!("{}", colors::bold(".")); eprintln!("{}", colors::bold("."));
if let Some(api_name) = api_name { if let Some(api_name) = api_name {
eprintln!(" ├ Requested by `{api_name}` API"); eprintln!("├ Requested by `{api_name}` API");
} }
let msg = format!("Run again with --allow-{name} to bypass this prompt."); let msg = format!("Run again with --allow-{name} to bypass this prompt.");
eprintln!(" {}", colors::italic(&msg)); eprintln!("{}", colors::italic(&msg));
eprint!(" {}", colors::bold("Allow?")); eprint!("{}", colors::bold("Allow?"));
eprint!(" {OPTS} > "); eprint!(" {OPTS} > ");
let value = loop { let value = loop {
let mut input = String::new(); let mut input = String::new();
@ -237,7 +237,7 @@ impl PermissionPrompter for TtyPrompter {
_ => { _ => {
// If we don't get a recognized option try again. // If we don't get a recognized option try again.
clear_n_lines(1); clear_n_lines(1);
eprint!(" {}", colors::bold("Unrecognized option. Allow?")); eprint!("{}", colors::bold("Unrecognized option. Allow?"));
eprint!(" {OPTS} > "); eprint!(" {OPTS} > ");
} }
}; };