3 releases

0.5.3 Jul 19, 2024
0.5.2 Nov 4, 2023
0.5.1 Nov 29, 2019

#182 in Text editors

Download history 668/week @ 2025-09-29 566/week @ 2025-10-06 555/week @ 2025-10-13 779/week @ 2025-10-20 568/week @ 2025-10-27 189/week @ 2025-11-03 747/week @ 2025-11-10 640/week @ 2025-11-17 508/week @ 2025-11-24 564/week @ 2025-12-01 491/week @ 2025-12-08 501/week @ 2025-12-15 813/week @ 2025-12-22 1027/week @ 2025-12-29 888/week @ 2026-01-05 759/week @ 2026-01-12

3,575 downloads per month
Used in 2 crates

MIT license

235KB
6K SLoC

liner

A Rust library offering readline-like functionality.

CONTRIBUTING.md

Build Status Docs

Features

  • 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.3"
...

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

~2.5MB
~41K SLoC