From 3b62e05062805d45fd626ac8e413e9b7aee7c3a1 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira <118899497+lucasfernog-crabnebula@users.noreply.github.com> Date: Thu, 17 Oct 2024 13:39:18 -0300 Subject: [PATCH] feat(permissions): expose PermissionPrompter and set_prompter function (#26327) when defining a custom runtime, it might be useful to define a custom prompter - for instance when you are not relying on the terminal and want a GUI prompter instead --- runtime/permissions/lib.rs | 2 ++ runtime/permissions/prompter.rs | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/runtime/permissions/lib.rs b/runtime/permissions/lib.rs index 2904242dae..0cd489b179 100644 --- a/runtime/permissions/lib.rs +++ b/runtime/permissions/lib.rs @@ -39,6 +39,8 @@ use prompter::PromptResponse; use prompter::PERMISSION_EMOJI; pub use prompter::set_prompt_callbacks; +pub use prompter::set_prompter; +pub use prompter::PermissionPrompter; pub use prompter::PromptCallback; /// Fast exit from permission check routines if this permission diff --git a/runtime/permissions/prompter.rs b/runtime/permissions/prompter.rs index 3d7536928e..316911edc1 100644 --- a/runtime/permissions/prompter.rs +++ b/runtime/permissions/prompter.rs @@ -80,6 +80,10 @@ pub fn set_prompt_callbacks( *MAYBE_AFTER_PROMPT_CALLBACK.lock() = Some(after_callback); } +pub fn set_prompter(prompter: Box) { + *PERMISSION_PROMPTER.lock() = prompter; +} + pub type PromptCallback = Box; pub trait PermissionPrompter: Send + Sync { @@ -476,8 +480,4 @@ pub mod tests { STUB_PROMPT_VALUE.store(value, Ordering::SeqCst); } } - - pub fn set_prompter(prompter: Box) { - *PERMISSION_PROMPTER.lock() = prompter; - } }