1 unstable release
0.1.0 | Jul 24, 2021 |
---|
#371 in Value formatting
9KB
90 lines
Formations
Formations is a rust library to allow you to easily create terminal forms, where a user is presented with multiple options and has to pick one. It looks something like:
1) Option 1 2) Option 2
3) Option 3 4) Option 4
It can be programmed as follows:
use formations::FormElement;
fn main() -> std::io::Result<()> {
println!("Pick your favourite pet.");
let mut form = vec![
FormElement::new("cat", "Small mammal with fur"),
FormElement::new("dog", "Likes a bone"),
FormElement::new("mouse", "Likes cheese"),
];
println!("{}", FormElement::run(&form)?.description.unwrap());
Ok(())
}
lib.rs
:
Formations
Formations is a rust library to allow you to easily create terminal forms, where a user is presented with multiple options and has to pick one. It looks something like:
1) Option 1 2) Option 2
3) Option 3 4) Option 4
It can be programmed as follows:
use formations::FormElement;
fn main() -> std::io::Result<()> {
println!("Pick your favourite pet.");
let mut form = vec![
FormElement::new("cat", "Small mammal with fur"),
FormElement::new("dog", "Likes a bone"),
FormElement::new("mouse", "Likes cheese"),
];
println!("{}", FormElement::run(&form)?.description.unwrap());
Ok(())
}
Dependencies
~1.2–1.6MB
~21K SLoC