Crates.io | console-menu |
lib.rs | console-menu |
version | 0.2.1 |
source | src |
created_at | 2023-12-01 23:04:37.718752 |
updated_at | 2024-03-11 17:04:02.856779 |
description | A simple yet powerful library for creating beautiful console menus in rust. |
homepage | https://github.com/Bdeering1/console-menu#readme |
repository | https://github.com/Bdeering1/console-menu |
max_upload_size | |
id | 1055724 |
size | 16,328 |
A simple yet powerful library for creating beautiful console menus in rust.
To get started, create a Menu object and pass it a list of MenuOptions. A simple example:
use console_menu::{Menu, MenuOption, MenuProps};
let menu_options = vec![
MenuOption::new("option 1", || println!("option one!")),
MenuOption::new("option 2", || println!("option two!")),
MenuOption::new("option 3", || println!("option three!")),
];
let mut menu = Menu::new(menu_options, MenuProps::default());
menu.show();
Menus are controlled using the arrow keys to move around, enter to select an option, and escape to exit. Vim style keybindings are also supported. Menus can include a title, footer message, and any combination of 8-bit colored backgrounds and text.
let menu_options = vec![
MenuOption::new("eggs", || println!("menu item one!")),
MenuOption::new("bacon", || println!("menu item two!")),
MenuOption::new("toast", || println!("menu item three!")),
];
let mut menu = Menu::new(menu_options, MenuProps {
title: "My Breakfast Menu",
message: "*coffee is free!",
fg_color: 233,
bg_color: 32,
msg_color: Some(236),
..MenuProps::default()
});
menu.show();
Menus can be nested, and options can include any type of callback. Please refer to the docs for more information.