Crates.io | redox_liner |
lib.rs | redox_liner |
version | 0.5.3 |
source | src |
created_at | 2019-11-29 16:48:08.253623 |
updated_at | 2024-07-19 19:17:56.713947 |
description | A library offering readline-like functionality. |
homepage | https://gitlab.redox-os.org/redox-os/liner |
repository | https://gitlab.redox-os.org/redox-os/liner |
max_upload_size | |
id | 185338 |
size | 252,205 |
A Rust library offering readline-like functionality.
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.
MIT licensed. See the LICENSE
file.