#console #terminal #ui


A library for simple (usually command-line) user interaction

2 releases

Uses old Rust 2015

0.1.1 Feb 1, 2016
0.1.0 Nov 12, 2015

#31 in #console

Download history 20/week @ 2021-01-20 24/week @ 2021-01-27 14/week @ 2021-02-03 18/week @ 2021-02-10 20/week @ 2021-02-17 44/week @ 2021-02-24 18/week @ 2021-03-03 12/week @ 2021-03-10 14/week @ 2021-03-17 28/week @ 2021-03-24 20/week @ 2021-03-31 22/week @ 2021-04-07 35/week @ 2021-04-14 26/week @ 2021-04-21 27/week @ 2021-04-28 18/week @ 2021-05-05

84 downloads per month
Used in 48 crates (2 directly)


111 lines

interactor crates.io Build Status API Docs unlicense

A Rust library for simple (usually command-line) user interaction.

  • Reading input from the console with a callback for each byte (e.g. for displaying colorhash256 for a password)
  • Selecting an item from a list using an external menu program (usually a fuzzy finder) or a built-in simple menu
  • Selecting a file using the "item from a list" thing above

Menu program?

A program that accepts a newline-separated list of items on stdin, presents a UI to the user (directly on /dev/tty if it's a CLI; can also be a GUI), and outputs the selected item on stdout.

You should let the users of your application pick their own favorite tool as a config option.
I propose the $MENU environment variable, like $EDITOR, as a place to look for user preference.


extern crate interactor;
use interactor::*;

fn main() {
    let read_result = read_from_tty(|buf, b, tty| {
        tty.write(&format!("({:?} | {})\n", buf, b).into_bytes());
    }, false, false).unwrap();
    println!("Read: {}", String::from_utf8(read_result).unwrap());

    let chosen_ext = pick_from_list(default_menu_cmd().as_mut(), &["first", "second"], "Selection: ").unwrap();
    println!("Congratulations, you chose '{}'!!", chosen_ext);


Please feel free to submit pull requests!

By participating in this project you agree to follow the Contributor Code of Conduct.

The list of contributors is available on GitHub.


This is free and unencumbered software released into the public domain.
For more information, please refer to the UNLICENSE file or unlicense.org.