Expand description
menu_rs is a library for Rust that allows the creation of simple and interactable command-line menus.
It’s very simple to use, you just create a Menu, adds the option you want it to have with the correspondent action to be run when selected and that’s it! You can use the arrow keys to move through the options, ENTER to select an option and ESC to exit the menu.
§Example
use menu_rs::{Menu, MenuOption};
let my_variable: u32 = 157;
fn action_1() {
println!("action 1")
}
fn action_2(val: u32) {
println!("action 2 with number {}", val)
}
fn action_3(msg: &str, val: f32) {
println!("action 3 with string {} and float {}", msg, val)
}
fn action_4() {
println!("action 4")
}
let menu = Menu::new(vec![
MenuOption::new("Option 1", action_1).hint("Hint for option 1"),
MenuOption::new("Option 2", || action_2(42)),
MenuOption::new("Option 3", || action_3("example", 3.14)),
MenuOption::new("Option 4", action_4),
MenuOption::new("Option 5", move || action_2(my_variable)),
]);
menu.show();
Structs§
- Menu
- The Menu to be shown in the command line interface.
- Menu
Option - A option that can be added to a Menu.