mod backend;
use backend::database;
use clap::Clap;
#[derive(Clap)]
#[clap(
name = clap::crate_name!(),
version = clap::crate_version!(),
author = clap::crate_authors!(),
about = clap::crate_description!(),
)]
struct Opts {
#[clap(required(true))]
filename: String,
#[clap(long, possible_values(&["error", "warn", "info", "debug", "trace"]),
default_value("error"))]
log_level: log::Level,
}
fn main() {
let opts = Opts::parse();
log::info!("Log level: {}", &opts.log_level);
let _db = database::Database::open(&opts.filename);
let mut editor = rustyline::Editor::<()>::new();
editor.bind_sequence(
rustyline::KeyEvent::alt('N'),
rustyline::Cmd::HistorySearchForward,
);
editor.bind_sequence(
rustyline::KeyEvent::alt('P'),
rustyline::Cmd::HistorySearchBackward,
);
loop {
let readline = editor.readline(&format!("{}> ", clap::crate_name!()));
match readline {
Ok(line) => {
println!("Command: {}", line);
}
Err(rustyline::error::ReadlineError::Interrupted) => {
println!("CTRL-C");
break;
}
Err(rustyline::error::ReadlineError::Eof) => {
println!("EOF");
break;
}
Err(err) => {
panic!("{}", err);
}
}
}
}