Browse Source

init++

fix-typo
Coin de Gamma 3 months ago
parent
commit
76ff813f98
  1. 10
      src/main.rs
  2. 19
      src/storage.rs

10
src/main.rs

@ -78,6 +78,13 @@ impl MPS {
MPS { storage: None }
}
fn print_init_hint() {
println!("1. Create empty repository for storing your passwords on gitlab or somewhere you prefer");
println!("2. Clone to your home folder ~/.mps/storage");
println!("3. Set variable $MPS_HOME=\"~/.mps/\"");
println!("4. Add to your $PATH:<path_to_msp> where you installed your mps");
println!("5. Run mps init");
}
fn prompt_new_password() -> io::Result<String> {
print!("Enter passphrase for storage: ");
@ -191,7 +198,6 @@ impl MPS {
format!("Can`t find id: {}", id)
));
}
let item = st.get(id);
editor::open_to_show(&item.content)?;
Ok(())
@ -224,7 +230,7 @@ fn run_command() -> io::Result<()> {
if !Storage::is_inited()? {
match get_prompt("Do you want to init your storage?")? {
PROMPT::YES => MPS::init()?,
PROMPT::NO => Storage::print_init_hint()?,
PROMPT::NO => MPS::print_init_hint(),
}
} else {
let mut mps = MPS::new();

19
src/storage.rs

@ -159,16 +159,17 @@ impl Storage {
Ok(())
}
pub fn print_init_hint() -> io::Result<()> {
println!("mps can work only when storage inited.");
println!("Hint: you can restore your storage if you have it already:");
println!(" git clone <your_storage_git_url> {}", Storage::get_storage_path()?);
println!("to init manually your storage and config");
Ok(())
}
pub fn is_inited() -> io::Result<bool> {
// TODO: check db
let sp = Storage::get_storage_path()?;
let storage_path = Path::new(&sp);
// Check if the folder exists and is a directory
if !storage_path.exists() || !storage_path.is_dir() {
return Err(io::Error::new(
io::ErrorKind::NotFound,
format!("{} does not exist or not a dir", Storage::get_storage_path()?)
));
}
// TODO check git
//let path = Path::new(&*STORAGE_FOLDER);
//return path.exists();

Loading…
Cancel
Save