diff --git a/src/main.rs b/src/main.rs index a04939d..f5921c2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -109,7 +109,7 @@ impl MPS { if Storage::is_inited()? { return Err(io::Error::new(io::ErrorKind::AlreadyExists, "Reinitialization attempted")); } - let mut passphrase = String::from(""); + let passphrase; loop { match MPS::prompt_new_password() { Ok(ps) => { @@ -143,11 +143,13 @@ impl MPS { fn list(&mut self) -> io:: Result<()> { self.login()?; let ids = self.storage.as_ref().unwrap().ids(); + let mut counter = 1; if ids.len() == 0 { println!("No items"); } else { for id in ids { - println!("{}", id); + println!("[{}] {}", counter, id); + counter += 1; } } Ok(()) @@ -234,10 +236,18 @@ fn run_command() -> io::Result<()> { mps.edit(id)? } None => { + match Storage::check_installed() { + Ok(()) => (), + Err(e) => { + println!("{}", e); + MPS::print_init_hint(); + return Ok(()); + } + } if !Storage::is_inited()? { - match get_prompt("Do you want to init your storage?")? { + match get_prompt("Do you want to init storage db?")? { PROMPT::YES => MPS::init()?, - PROMPT::NO => MPS::print_init_hint(), + PROMPT::NO => return Ok(()), } } else { let mut mps = MPS::new();