Ask
A simple toolset for asking questions through the terminal.
Usage
extern crate ask;
use ask::question::{OpenEnded, MultipleChoice, OptionGroup, TraitQuestion};
fn main() {
let answer_collections = multiple_choice
.add_option_group(
OptionGroup::new("Entrees")
.add_option("Calamari".to_owned())
.add_option("Buffalo wings".to_owned())
.add_option("Shrimp".to_owned())
)
.add_option_group(
OptionGroup::new("Main Coarse")
.add_option("T-Bone".to_owned())
.add_option("Burger".to_owned())
.add_option("Duck".to_owned())
)
.set_validation(Box::new(|answer_collection| {
validate::group_options::selections_are_gtoe(& answer_collection, 0) &&
validate::group_options::selections_are_ltoe(& answer_collection, 3)
})
)
// .replace_continue_btn("CAN CONTINUE!!".to_owned(), "CANNOT CONTINUE!!".to_owned()) //can customize continue btn
.send()
.unwrap();
println!("");
// let answer_collections = multiple_choice.to_answer_collections(); //can pull the answer_collections at any time
for answer_sets in answer_collections.answer_sets{
for answer in answer_sets.answers{
println!("{}", answer);
}
}
should show: