1 unstable release

✓ Uses Rust 2018 edition

0.5.1 Nov 29, 2019

#98 in Command-line interface

Download history 111/week @ 2019-12-02 95/week @ 2019-12-09 68/week @ 2019-12-16 47/week @ 2019-12-23 29/week @ 2019-12-30 43/week @ 2020-01-06 35/week @ 2020-01-13 60/week @ 2020-01-20 48/week @ 2020-01-27 51/week @ 2020-02-03 46/week @ 2020-02-10 56/week @ 2020-02-17 61/week @ 2020-02-24 52/week @ 2020-03-02 84/week @ 2020-03-09 36/week @ 2020-03-16

123 downloads per month
Used in 3 crates (2 directly)

MIT license

295KB
7.5K SLoC

liner

A Rust library offering readline-like functionality.

CONTRIBUTING.md

crates.io Build Status Docs

Featues

  • Autosuggestions
  • Emacs and Vi keybindings
  • Multi-line editing
  • History
  • (Incomplete) basic and filename completions
  • Reverse search
  • Remappable keybindings

Basic Usage

In Cargo.toml:

[dependencies]
redox_liner = "0.5.1"
...

In src/main.rs:

extern crate liner;

use liner::{Context, Completer};

struct EmptyCompleter;

impl<W: std::io::Write> Completer<W> for EmptyCompleter {
    fn completions(&mut self, _start: &str) -> Vec<String> {
        Vec::new()
    }
}

fn main() {
    let mut con = Context::new();

    loop {
        let res = con.read_line("[prompt]$ ", &mut EmptyCompleter).unwrap();

        if res.is_empty() {
            break;
        }

        con.history.push(res.into());
    }
}

See src/main.rs for a more sophisticated example.

License

MIT licensed. See the LICENSE file.

Dependencies

~355KB