Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bdeering1/console-menu
A simple yet powerful library for creating beautiful console menus in rust.
https://github.com/bdeering1/console-menu
Last synced: 7 days ago
JSON representation
A simple yet powerful library for creating beautiful console menus in rust.
- Host: GitHub
- URL: https://github.com/bdeering1/console-menu
- Owner: Bdeering1
- Created: 2023-06-13T03:28:14.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-18T21:36:31.000Z (about 2 months ago)
- Last Synced: 2025-02-02T09:11:17.666Z (9 days ago)
- Language: Rust
- Homepage:
- Size: 28.3 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
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:
```rust
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](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) colored backgrounds and text. Color constants are also available to simplify theming.
```rust
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();
```Menus can be nested, and options can include any type of callback. Please refer to the [docs](https://docs.rs/console-menu/) for more information.