console-menu

Crates.ioconsole-menu
lib.rsconsole-menu
version0.3.1
created_at2023-12-01 23:04:37.718752+00
updated_at2025-03-15 17:43:18.786494+00
descriptionA simple yet powerful library for creating beautiful console menus in rust.
homepagehttps://github.com/Bdeering1/console-menu#readme
repositoryhttps://github.com/Bdeering1/console-menu
max_upload_size
id1055724
size17,431
Bryn Deering (Bdeering1)

documentation

README

Console Menu

A simple yet powerful library for creating beautiful console menus in rust.

Usage

To get started, create a Menu object and pass it a list of MenuOptions. Each option consists of a label and a callback. 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();
Screen Shot 2023-11-26 at 6 09 02 PM

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. Color constants are also available to simplify theming.

use console_menu::{color, Menu, MenuOption, MenuProps};

let menu_options = vec![
    MenuOption::new("eggs", || println!("eggs coming right up!")),
    MenuOption::new("bacon", || println!("bacon it is!")),
    MenuOption::new("toast", || println!("sorry, we're out of toast")),
];

let mut menu = Menu::new(menu_options, MenuProps {
    title: "My Breakfast Menu",
    message: "*coffee is free!",
    fg_color: color::BLACK,
    bg_color: color::BLUE,
    msg_color: Some(color::DARK_GRAY),
    ..MenuProps::default()
});
menu.show();
Screen Shot 2023-11-29 at 12 56 45 PM

Menus can be nested, and options can include any type of callback. Please refer to the docs for more information.

Commit count: 35

cargo fmt