mirror of
https://github.com/Qortal/piratewallet-light-cli.git
synced 2025-02-01 03:12:15 +00:00
Cleanup
This commit is contained in:
parent
48d305c406
commit
d308772965
@ -39,6 +39,7 @@ impl Command for HelpCommand {
|
||||
|
||||
fn exec(&self, _args: &[String], _: &mut LightClient) {
|
||||
// Print a list of all commands
|
||||
println!("Available commands:");
|
||||
get_commands().iter().for_each(| (cmd, obj) | {
|
||||
println!("{} - {}", cmd, obj.short_help());
|
||||
});
|
||||
|
@ -1,5 +1,6 @@
|
||||
use crate::lightwallet::LightWallet;
|
||||
|
||||
use std::path::Path;
|
||||
use std::fs::File;
|
||||
use std::io;
|
||||
use std::io::prelude::*;
|
||||
@ -63,9 +64,20 @@ impl LightClient {
|
||||
}
|
||||
|
||||
pub fn do_read(&mut self) {
|
||||
if !Path::new("wallet.dat").exists() {
|
||||
println!("No existing wallet");
|
||||
return;
|
||||
}
|
||||
|
||||
print!("Reading wallet...");
|
||||
io::stdout().flush().ok().expect("Could not flush stdout");
|
||||
let mut file_buffer = File::open("wallet.dat").unwrap();
|
||||
let mut file_buffer = match File::open("wallet.dat") {
|
||||
Ok(f) => f,
|
||||
Err(e) => {
|
||||
println!("[Error: {}]", e.description());
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let lw = LightWallet::read(&mut file_buffer).unwrap();
|
||||
self.wallet = Arc::new(lw);
|
||||
|
@ -16,6 +16,7 @@ pub mod grpc_client {
|
||||
|
||||
|
||||
pub fn main() {
|
||||
println!("Starting Light Client");
|
||||
let mut lightclient = LightClient::new();
|
||||
|
||||
// At startup, read the wallet.dat
|
||||
@ -23,11 +24,12 @@ pub fn main() {
|
||||
|
||||
// `()` 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.");
|
||||
}
|
||||
let _ = rl.load_history("history.txt");
|
||||
|
||||
println!("Ready!");
|
||||
|
||||
loop {
|
||||
let readline = rl.readline(&format!("Block:{} (h for help) >> ", lightclient.last_scanned_height()));
|
||||
let readline = rl.readline(&format!("Block:{} (type 'help') >> ", lightclient.last_scanned_height()));
|
||||
match readline {
|
||||
Ok(line) => {
|
||||
rl.add_history_entry(line.as_str());
|
||||
|
Loading…
Reference in New Issue
Block a user