pub struct PromptSelectOption {
pub value: String,
pub label: String,
}
Expand description
Use to define options for CliPrompt::prompt_select
, CliPrompt::prompt_multi_select
Fields§
§value: String
§label: String
Implementations§
Source§impl PromptSelectOption
impl PromptSelectOption
Sourcepub fn new(value: &str, label: &str) -> Self
pub fn new(value: &str, label: &str) -> Self
Examples found in repository?
examples/example1.rs (line 18)
4fn main() {
5 let mut cli_prompt = CliPrompt::new();
6 cli_prompt.intro("example app").unwrap();
7
8 cli_prompt.prompt_text("Enter your name").unwrap();
9
10 let answer = cli_prompt.prompt_confirm("Are you sure?").unwrap();
11
12 if !answer {
13 cli_prompt.cancel("Operation cancelled").unwrap();
14 exit(0);
15 }
16
17 let options = vec![
18 PromptSelectOption::new("option1", "Pikachu"),
19 PromptSelectOption::new("option2", "Charmander"),
20 PromptSelectOption::new("option3", "Squirtle"),
21 ];
22 let selected_option = cli_prompt
23 .prompt_select("Which one do you prefer?", options)
24 .unwrap();
25
26 cli_prompt
27 .log(&format!("{}", selected_option), LogType::Info)
28 .unwrap();
29 cli_prompt.outro("Good Bye").unwrap();
30}
Trait Implementations§
Source§impl Clone for PromptSelectOption
impl Clone for PromptSelectOption
Source§fn clone(&self) -> PromptSelectOption
fn clone(&self) -> PromptSelectOption
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for PromptSelectOption
impl Debug for PromptSelectOption
Source§impl Display for PromptSelectOption
impl Display for PromptSelectOption
Source§impl PartialEq for PromptSelectOption
impl PartialEq for PromptSelectOption
impl Eq for PromptSelectOption
impl StructuralPartialEq for PromptSelectOption
Auto Trait Implementations§
impl Freeze for PromptSelectOption
impl RefUnwindSafe for PromptSelectOption
impl Send for PromptSelectOption
impl Sync for PromptSelectOption
impl Unpin for PromptSelectOption
impl UnwindSafe for PromptSelectOption
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