File: sqlite_history.rs

package info (click to toggle)
rust-rustyline 17.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,032 kB
  • sloc: makefile: 2
file content (17 lines) | stat: -rw-r--r-- 532 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use rustyline::{Config, Editor, Result};

fn main() -> Result<()> {
    let config = Config::builder().auto_add_history(true).build();
    let history = if false {
        // memory
        rustyline::sqlite_history::SQLiteHistory::with_config(&config)?
    } else {
        // file
        rustyline::sqlite_history::SQLiteHistory::open(&config, "history.sqlite3")?
    };
    let mut rl: Editor<(), _> = Editor::with_history(config, history)?;
    loop {
        let line = rl.readline("> ")?;
        println!("{line}");
    }
}