pub struct Prompt { /* private fields */ }Expand description
Ask for a line of text. Port of rich.prompt.Prompt.
let console = Console::new();
let name = Prompt::new("What is your name").ask(&console, Some("World")).unwrap();Implementations§
Source§impl Prompt
impl Prompt
pub fn new(prompt: impl Into<String>) -> Self
Sourcepub fn choices(
self,
choices: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn choices( self, choices: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Restrict answers to choices, shown as [a/b/c].
Sourcepub fn case_sensitive(self, case_sensitive: bool) -> Self
pub fn case_sensitive(self, case_sensitive: bool) -> Self
Match choices regardless of case, returning the choice as spelled in the list rather than as typed.
Sourcepub fn show_default(self, show: bool) -> Self
pub fn show_default(self, show: bool) -> Self
Hide the (default) hint while still accepting an empty answer.
Sourcepub fn show_choices(self, show: bool) -> Self
pub fn show_choices(self, show: bool) -> Self
Hide the [a/b/c] hint while still enforcing the choices.
Sourcepub fn make_prompt(&self, console: &Console, default: Option<&str>) -> Text
pub fn make_prompt(&self, console: &Console, default: Option<&str>) -> Text
The rendered question, as ask would print it.
Sourcepub fn process_response(&self, value: &str) -> Result<String, InvalidResponse>
pub fn process_response(&self, value: &str) -> Result<String, InvalidResponse>
Validate one answer. Port of PromptBase.process_response.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Prompt
impl RefUnwindSafe for Prompt
impl Send for Prompt
impl Sync for Prompt
impl Unpin for Prompt
impl UnsafeUnpin for Prompt
impl UnwindSafe for Prompt
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more