Browse Source

init++

fix-typo
Coin de Gamma 3 months ago
parent
commit
be2bb6a9b4
  1. 18
      src/main.rs

18
src/main.rs

@ -109,7 +109,7 @@ impl MPS {
if Storage::is_inited()? { if Storage::is_inited()? {
return Err(io::Error::new(io::ErrorKind::AlreadyExists, "Reinitialization attempted")); return Err(io::Error::new(io::ErrorKind::AlreadyExists, "Reinitialization attempted"));
} }
let mut passphrase = String::from(""); let passphrase;
loop { loop {
match MPS::prompt_new_password() { match MPS::prompt_new_password() {
Ok(ps) => { Ok(ps) => {
@ -143,11 +143,13 @@ impl MPS {
fn list(&mut self) -> io:: Result<()> { fn list(&mut self) -> io:: Result<()> {
self.login()?; self.login()?;
let ids = self.storage.as_ref().unwrap().ids(); let ids = self.storage.as_ref().unwrap().ids();
let mut counter = 1;
if ids.len() == 0 { if ids.len() == 0 {
println!("No items"); println!("No items");
} else { } else {
for id in ids { for id in ids {
println!("{}", id); println!("[{}] {}", counter, id);
counter += 1;
} }
} }
Ok(()) Ok(())
@ -234,10 +236,18 @@ fn run_command() -> io::Result<()> {
mps.edit(id)? mps.edit(id)?
} }
None => { None => {
match Storage::check_installed() {
Ok(()) => (),
Err(e) => {
println!("{}", e);
MPS::print_init_hint();
return Ok(());
}
}
if !Storage::is_inited()? { 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::YES => MPS::init()?,
PROMPT::NO => MPS::print_init_hint(), PROMPT::NO => return Ok(()),
} }
} else { } else {
let mut mps = MPS::new(); let mut mps = MPS::new();

Loading…
Cancel
Save