pub fn select<M: Display, T: Clone, O: Display + Clone>(
message: M
) -> Select<M, T, O>Expand description
Shorthand for Select::new()
Examples found in repository?
examples/generic_select.rs (line 26)
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
fn main() -> Result<(), ClackError> {
println!();
intro(style(" generic select ").reverse());
let select_string = select("select string")
.option("val1", SelectEnum::One)
.option("val2", SelectEnum::One)
.option("val3", SelectEnum::One)
.interact()?;
let select_enum = select("select enum")
.option(SelectEnum::One, SelectEnum::One)
.option(SelectEnum::Two, SelectEnum::Two)
.option(SelectEnum::Three, SelectEnum::Three)
.interact()?;
let multi_enum = multi_select("multi_select enum")
.option(SelectEnum::One, "one")
.option(SelectEnum::Two, "two")
.option(SelectEnum::Three, "three")
.interact()?;
outro("");
println!("select string, label enum {:?}", select_string);
println!("select enum, label enum {:?}", select_enum);
println!("multi select enum, label string {:?}", multi_enum);
Ok(())
}More examples
examples/full.rs (line 24)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
fn main() -> Result<(), ClackError> {
println!();
intro(style(" full ").reverse());
let do_input = input("input")
.default_value("default")
.cancel(do_cancel)
.interact()?;
let do_multi_input = multi_input("multi input")
.max(4)
.cancel(do_cancel)
.interact()?;
let do_confirm = confirm("confirm").prompts("true", "false").interact()?;
let do_multi_select = multi_select("multi select")
.option("opt1", "option 1")
.option("opt2", "option 2")
.option_hint("opt3", "option 3", "hint")
.interact()?;
let do_select = select("select")
.option("val1", "value 1")
.option("val2", "value 2")
.option_hint("val 3", "value 3", "hint")
.interact()?;
outro("");
println!("input {:?}", do_input);
println!("confirm {:?}", do_confirm);
println!("multi_input {:?}", do_multi_input);
println!("multi_select {:?}", do_multi_select);
println!("select {:?}", do_select);
Ok(())
}examples/less.rs (line 12)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
fn main() -> Result<(), ClackError> {
println!();
intro(style(" less ").reverse());
let select_less = select("less")
.option("val 1", "value 1")
.option("val 2", "value 2")
.option_hint("val 3", "value 3", "hint")
.option("val 4", "value 4")
.option("val 5", "value 5")
.less(3)
.interact();
let multi_less_noop = multi_select("less")
.option("val 1", "value 1")
.option("val 2", "value 2")
.option_hint("val 3", "value 3", "hint")
.less(5)
.interact();
let multi_less = multi_select("less")
.option("val 1", "value 1")
.option("val 2", "value 2")
.option_hint("val 3", "value 3", "hint")
.option("val 4", "value 4")
.option("val 5", "value 5")
.less(3)
.interact();
let mut page_up_down = select("page up / down");
page_up_down.less(10);
for i in 0..100 {
page_up_down.option(i, i);
}
let page_up_down = page_up_down.interact()?;
outro("");
println!("page_up_down {:?}", page_up_down);
println!("select_less {:?}", select_less);
println!("multi_less_noop {:?}", multi_less_noop);
println!("multi_less {:?}", multi_less);
Ok(())
}