48 lines
1.2 KiB
Rust
Raw Normal View History

2019-09-03 12:03:00 -07:00
mod lightclient;
mod lightwallet;
2019-09-03 12:03:00 -07:00
mod address;
mod prover;
mod commands;
use lightclient::LightClient;
2019-09-03 12:03:00 -07:00
2019-09-03 17:01:34 -07:00
use rustyline::error::ReadlineError;
use rustyline::Editor;
2019-09-01 14:29:53 -07:00
pub mod grpc_client {
include!(concat!(env!("OUT_DIR"), "/cash.z.wallet.sdk.rpc.rs"));
}
2019-09-03 12:03:00 -07:00
2019-09-01 14:29:53 -07:00
pub fn main() {
2019-09-06 13:13:14 -07:00
let mut light_client = LightClient::new();
2019-09-03 17:01:34 -07:00
// `()` can be used when no completer is required
let mut rl = Editor::<()>::new();
if rl.load_history("history.txt").is_err() {
println!("No previous history.");
}
loop {
let readline = rl.readline(&format!("Block:{} (h for help) >> ", light_client.last_scanned_height()));
2019-09-03 17:01:34 -07:00
match readline {
Ok(line) => {
rl.add_history_entry(line.as_str());
2019-09-06 13:13:14 -07:00
commands::do_user_command(line, &mut light_client);
2019-09-03 17:01:34 -07:00
},
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();
2019-09-01 14:29:53 -07:00
}