xmenu

Crates.ioxmenu
lib.rsxmenu
version0.1.0
sourcesrc
created_at2024-05-15 21:12:39.263424
updated_at2024-05-15 21:12:39.263424
descriptionMake interactive menu with xmenu. More updates coming soon.
homepage
repositoryhttps://github.com/d33pster/xmenu
max_upload_size
id1241514
size468,858
Soumyo Deep Gupta (d33pster)

documentation

README

xmenu

Interactive terminal menu lib for rust.

Table of Contents

Overview

make interactive menus in rust. In case of any issues feel free to create an issue here or create a pull request.

Installation

cargo install xmenu

This will also install a bin named xmenu which can be called for simulating demos of xmenu working as well as fix an ISSUE in Windows terminal where ANSI colours are not displaying as it is supposed to. Instead, the colour codes are getting printed.

Just choose the option for fixing it after running xmenu in the terminal

xmenu

Usage

For in script usage,

use xmenu::{Xmenu, Colour};

fn main() {
    // define the menu
    let mut xm = Xmenu::new();
    
    // add options
    xm.add("Option1");
    xm.add("Option2");

    // run and collect result
    let result = xm.run(Colour::Blue); // this will make the selected option blue

    // create conditions
    if result == "Option1".to_string() {
        // do something
    } else if result == "Option2".to_string() {
        // do something else
    } else result == "Abort" {
        std::process::exit(0);
    }
}

Demo

For a demo, after installing xmenu using cargo install xmenu, run:

xmenu

in terminal.

Fix Windows CMD ANSI Colour Problem

After running xmenu in terminal, choose the third option.

Commit count: 8

cargo fmt