MenuGenie

Rust library for managing multi-level terminal menus. It provides simple builder API for creating nested menus.

Usage

A simple example application simple.rs

Menu actions

There are several menu actions that can execute when user selects a menu item

When the menu encounters the Nothing action it will return with Ok(Some((menu_id, menu_item_id))) so we can match against the returned touple. See the simple.rs example.

Builder

Builder starts of with empty vector of menus.

When we call with_menu(id) we insert another menu with the provided id.

with_menu_item(prompt, action) adds a generic menu item with the provided message and action. Each menu item has an id that is auto-generated when menu item is added to the menu. That menu item id is used when user makes a selection. Menu items are added to the last added menu so menu must exist before we add any menu items.

with_back_button() adds a menu item with text "Back", action Back and id 0.

with_quit_button() adds a menu item with text "Quit", action Quit and id 0.

Note If you want a back and a quit button at the same time you can add one with provided "shortcut" function and other with with_menu_item function.

Starting menu id is set when first menu is added but it can be modified with with_starting_menu function.

Finally to get a MenuGenie instance simply call build.

MenuGenie struct

MenuGenie struct holds the menus and the starting menu id. It works by saving a callstack of menu ids.

It has two functions for running the menu:

Note when we call build on MenuBuilder it places starting menu id onto the callstack so we can just call run.

Future

It the future I plan on adding more features and customizations to the library. If you have some ideas fell free to let me know. These are some ideas that came to my mind:

Contributions

Contributions and suggestions are always welcome. Fell free to participate in this project.