Skip to content
Snippets Groups Projects
Commit d0a1d759 authored by Main's avatar Main
Browse files

Update README.md for v0.1.0

parent 6cf9f5a6
No related branches found
No related tags found
No related merge requests found
......@@ -10,3 +10,49 @@ This project uses Cargo and Rust Stable
```bash
cargo build --release
```
## Example
``rust
extern crate rustyline;
use rustyline::error::ReadlineError;
use rustyline::Editor;
fn main() {
let mut rl = Editor::new();
if let Err(_) = rl.load_history("history.txt") {
println!("No previous history.");
}
loop {
let readline = rl.readline(">> ");
match readline {
Ok(line) => {
rl.add_history_entry(&line);
println!("Line: {}", line);
},
Err(ReadlineError::Interrupted) => {
println!("CTRL-C");
break
},
Err(ReadlineError::Eof) => {
println!("CTRL-D");
break
},
Err(err) => {
println!("Error: {:?}", err);
break
}
}
}
rl.save_history("history.txt").unwrap();
}
```
## crates.io
You can use this package in your project by adding the following
to your `Cargo.toml`:
``toml
[dependencies]
rustyline = "0.1.0"
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment