pub struct Confirm { /* private fields */ }Expand description
A yes-or-no field with an optional default answer.
Implementations§
Source§impl Confirm
impl Confirm
Sourcepub fn new(
key: FieldKey<ConfirmAnswer>,
question: impl Into<String>,
default: Option<bool>,
) -> Result<Self, FieldConfigError>
pub fn new( key: FieldKey<ConfirmAnswer>, question: impl Into<String>, default: Option<bool>, ) -> Result<Self, FieldConfigError>
Creates a confirmation field with an optional default answer.
Sourcepub fn labels(self, yes: impl Into<String>, no: impl Into<String>) -> Self
pub fn labels(self, yes: impl Into<String>, no: impl Into<String>) -> Self
Sets the labels shown for yes and no.
yes and no is plain text. Escape sequences in it are counted as ordinary
characters when the prompt measures its cells, so a pre-styled string
mis-aligns the field; style it through the prompt’s theme instead.
Sets the horizontal alignment of the yes and no buttons.
The default is Align::Left. Center and right alignment position the
buttons within the natural width of the question and description.
Sourcepub fn description(self, description: impl Into<String>) -> Self
pub fn description(self, description: impl Into<String>) -> Self
Sets supporting text shown below the question.
description is plain text. Escape sequences in it are counted as ordinary
characters when the prompt measures its cells, so a pre-styled string
mis-aligns the field; style it through the prompt’s theme instead.
Sourcepub fn help(self, help: impl Into<String>) -> Self
pub fn help(self, help: impl Into<String>) -> Self
Sets the navigation hint shown beneath the choices.
help is plain text. Escape sequences in it are counted as ordinary
characters when the prompt measures its cells, so a pre-styled string
mis-aligns the field; style it through the prompt’s theme instead.
Sourcepub fn unanswered_message(self, message: impl Into<String>) -> Self
pub fn unanswered_message(self, message: impl Into<String>) -> Self
Sets the message shown when a confirmation without a default is unanswered.