From 9da8c60340b8d8f43a2e5cadf7ec9a7b69d79173 Mon Sep 17 00:00:00 2001 From: Coin de Gamma Date: Fri, 27 Sep 2024 06:07:33 +0000 Subject: [PATCH] optional & new init inistructions --- README.md | 33 ++++++++++++++++++++++++--------- src/main.rs | 9 ++++----- src/paths.rs | 8 ++++---- 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 666fd4b..561c103 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ A small tool for storing passwords locally with git sync -## MPS +## Installation 1. Clone MPS repo: ``` git clone git@code.corpglory.net:corpglory/mps.git @@ -14,18 +14,33 @@ cd mps cargo build --release ``` -3. Add your mps build to PATH in your ~/.zshenv - +3. Run init ``` -export PATH=$PATH:"/target/release" +mps init +``` + +4. Add your storage under git +```bash +cd storage +git init +... # other git initialization process ``` -## Intilization +### Intilization with exisitng storage-db repo 1. Create empty repository for storing your passwords on gitlab or somewhere you prefer -2. Create dir `mps`: `mkdir ~/.mps` -3. Clone to your home folder `~/.mps/storage`: `git clone storage` -3. Export varable `$MPS_HOME`: `export MPS_HOME="/home//.mps"` in your `~/.zshenv` -4. Run `mps init` +2. Clone to your home folder `~/.mps/storage`: `git clone storage` + +#### Exporting `MPS_HOME` +You can export variable `$MPS_HOME` to init storage for example in your home directory: + +`export MPS_HOME="/home//.mps"` in your `~/.zshenv` +now `mps` will try to get storage from `$MPS_HOME/storage` + +#### Add your mps build to PATH in your ~/.zshenv + +``` +export PATH=$PATH:"/target/release" +``` diff --git a/src/main.rs b/src/main.rs index cafaf13..a365ce3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -86,11 +86,10 @@ impl MPS { } fn print_init_hint() { - println!("1. Create empty repository for storing your passwords on gitlab or somewhere you prefer"); - println!("2. Create dir `mps`: `mkdir ~/mps`"); - println!("3. Clone to your home folder `~/.mps/storage`: `git clone storage`"); - println!("4. Export varable `$MPS_HOME`: `export MPS_HOME=\"/home//.mps\"`"); - println!("5. Run `mps init`"); + println!("1. Run `mps init`"); + println!("2. Init `storage` under git:"); + println!(" cd storage"); + println!(" git init"); } fn prompt_new_password() -> io::Result { diff --git a/src/paths.rs b/src/paths.rs index c0af9e9..1fe2f22 100644 --- a/src/paths.rs +++ b/src/paths.rs @@ -9,10 +9,10 @@ pub static PATH_DB: &str = "db.mps"; pub fn get_storage_path() -> io::Result { - let mps_home = env::var(ENV_MPS_HOME).map_err(|err| { - io::Error::new(io::ErrorKind::NotFound, format!("{} error: {}", ENV_MPS_HOME, err)) - })?; - let result = format!("{}/{}", mps_home, PATH_STORAGE); + let result = match env::var(ENV_MPS_HOME) { + Ok(mps_home) => format!("{}/{}", mps_home, PATH_STORAGE), + Err(_) => PATH_STORAGE.to_string() + }; Ok(result) }