README.md 1.03 KB
Newer Older
MovingtoMars's avatar
MovingtoMars committed
1
2
3
# liner
A Rust library offering readline-like functionality.

MovingtoMars's avatar
MovingtoMars committed
4
5
[CONTRIBUTING.md](/CONTRIBUTING.md)

MovingtoMars's avatar
MovingtoMars committed
6
[![crates.io](https://meritbadge.herokuapp.com/liner)](https://crates.io/crates/liner)
MovingtoMars's avatar
MovingtoMars committed
7
[![Build Status](https://travis-ci.org/MovingtoMars/liner.svg)](https://travis-ci.org/MovingtoMars/liner)
MovingtoMars's avatar
MovingtoMars committed
8
[![Docs](https://docs.rs/liner/badge.svg)](https://docs.rs/liner/)
MovingtoMars's avatar
MovingtoMars committed
9

10
11
12
13
14
15
16
17
18
## Featues
- [x] Autosuggestions
- [x] Emacs and Vi keybindings
- [x] Multi-line editing
- [x] History
- [x] (Incomplete) basic and filename completions
- [ ] Reverse search
- [ ] Remappable keybindings

MovingtoMars's avatar
MovingtoMars committed
19
## Basic Usage
MovingtoMars's avatar
MovingtoMars committed
20
21
22
In `Cargo.toml`:
```toml
[dependencies]
23
liner = "0.4.5"
MovingtoMars's avatar
MovingtoMars committed
24
25
26
27
...
```

In `src/main.rs`:
MovingtoMars's avatar
MovingtoMars committed
28
29
30
31
32
33
34
35
36
37
38
39

```rust
extern crate liner;

use liner::Context;

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

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

40
        if res.is_empty() {
MovingtoMars's avatar
MovingtoMars committed
41
42
43
44
45
46
47
48
            break;
        }

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

MovingtoMars's avatar
MovingtoMars committed
49
50
**See src/main.rs for a more sophisticated example.**

MovingtoMars's avatar
MovingtoMars committed
51
52
## License
MIT licensed. See the `LICENSE` file.