diff options
author | Bartek Iwańczuk <biwanczuk@gmail.com> | 2024-08-08 14:39:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-08 15:39:31 +0200 |
commit | ab8802f49b882651b1bb7057aca79d13e077ef50 (patch) | |
tree | f1471f776b063559c7a594e353449ab509987ab4 /runtime/permissions | |
parent | e9e3ab462863fdaf1c0639c53da16c737a0d913b (diff) |
feat(permissions): link to docs in permission prompt (#24948)
This commit updates permission prompt to add a link
to the documentation for particular flag.
Additionally the box drawings around the prompt have been slightly
altered for better visibility.
<img width="737" alt="Screenshot 2024-08-08 at 12 42 32"
src="https://github.com/user-attachments/assets/6ae748cd-4f29-439d-b0ee-f28f565f211a">
Diffstat (limited to 'runtime/permissions')
-rw-r--r-- | runtime/permissions/prompter.rs | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/runtime/permissions/prompter.rs b/runtime/permissions/prompter.rs index 59a3a2f7b..050902d59 100644 --- a/runtime/permissions/prompter.rs +++ b/runtime/permissions/prompter.rs @@ -319,16 +319,29 @@ impl PermissionPrompter for TtyPrompter { // output everything in one shot to make the tests more reliable { let mut output = String::new(); - write!(&mut output, "┌ {PERMISSION_EMOJI} ").unwrap(); + write!(&mut output, "┏ {PERMISSION_EMOJI} ").unwrap(); write!(&mut output, "{}", colors::bold("Deno requests ")).unwrap(); write!(&mut output, "{}", colors::bold(message.clone())).unwrap(); writeln!(&mut output, "{}", colors::bold(".")).unwrap(); if let Some(api_name) = api_name.clone() { - writeln!(&mut output, "├ Requested by `{api_name}` API.").unwrap(); + writeln!( + &mut output, + "┠─ Requested by `{}` API.", + colors::bold(api_name) + ) + .unwrap(); } + let msg = format!( + "Learn more at: {}", + colors::cyan_with_underline(&format!( + "https://docs.deno.com/go/--allow-{}", + name + )) + ); + writeln!(&mut output, "┠─ {}", colors::italic(&msg)).unwrap(); let msg = format!("Run again with --allow-{name} to bypass this prompt."); - writeln!(&mut output, "├ {}", colors::italic(&msg)).unwrap(); - write!(&mut output, "└ {}", colors::bold("Allow?")).unwrap(); + writeln!(&mut output, "┠─ {}", colors::italic(&msg)).unwrap(); + write!(&mut output, "┗ {}", colors::bold("Allow?")).unwrap(); write!(&mut output, " {opts} > ").unwrap(); stderr_lock.write_all(output.as_bytes()).unwrap(); @@ -355,7 +368,7 @@ impl PermissionPrompter for TtyPrompter { 'y' | 'Y' => { clear_n_lines( &mut stderr_lock, - if api_name.is_some() { 4 } else { 3 }, + if api_name.is_some() { 5 } else { 4 }, ); let msg = format!("Granted {message}."); writeln!(stderr_lock, "✅ {}", colors::bold(&msg)).unwrap(); @@ -364,7 +377,7 @@ impl PermissionPrompter for TtyPrompter { 'n' | 'N' | '\x1b' => { clear_n_lines( &mut stderr_lock, - if api_name.is_some() { 4 } else { 3 }, + if api_name.is_some() { 5 } else { 4 }, ); let msg = format!("Denied {message}."); writeln!(stderr_lock, "❌ {}", colors::bold(&msg)).unwrap(); @@ -373,7 +386,7 @@ impl PermissionPrompter for TtyPrompter { 'A' if is_unary => { clear_n_lines( &mut stderr_lock, - if api_name.is_some() { 4 } else { 3 }, + if api_name.is_some() { 5 } else { 4 }, ); let msg = format!("Granted all {name} access."); writeln!(stderr_lock, "✅ {}", colors::bold(&msg)).unwrap(); @@ -384,7 +397,7 @@ impl PermissionPrompter for TtyPrompter { clear_n_lines(&mut stderr_lock, 1); write!( stderr_lock, - "└ {} {opts} > ", + "┗ {} {opts} > ", colors::bold("Unrecognized option. Allow?") ) .unwrap(); |