Browse Source

optional & new init inistructions

item-number-refactoring
Coin de Gamma 3 months ago
parent
commit
9da8c60340
  1. 33
      README.md
  2. 9
      src/main.rs
  3. 8
      src/paths.rs

33
README.md

@ -2,7 +2,7 @@
A small tool for storing passwords locally with git sync A small tool for storing passwords locally with git sync
## MPS ## Installation
1. Clone MPS repo: 1. Clone MPS repo:
``` ```
git clone git@code.corpglory.net:corpglory/mps.git git clone git@code.corpglory.net:corpglory/mps.git
@ -14,18 +14,33 @@ cd mps
cargo build --release cargo build --release
``` ```
3. Add your mps build to PATH in your ~/.zshenv 3. Run init
``` ```
export PATH=$PATH:"<mps_git_repo_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 1. Create empty repository for storing your passwords on gitlab or somewhere you prefer
2. Create dir `mps`: `mkdir ~/.mps` 2. Clone to your home folder `~/.mps/storage`: `git clone <your_storage_url> storage`
3. Clone to your home folder `~/.mps/storage`: `git clone <your_storage_url> storage`
3. Export varable `$MPS_HOME`: `export MPS_HOME="/home/<your_username>/.mps"` in your `~/.zshenv` #### Exporting `MPS_HOME`
4. Run `mps init` You can export variable `$MPS_HOME` to init storage for example in your home directory:
`export MPS_HOME="/home/<your_username>/.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:"<mps_git_repo_path>/target/release"
```

9
src/main.rs

@ -86,11 +86,10 @@ impl MPS {
} }
fn print_init_hint() { fn print_init_hint() {
println!("1. Create empty repository for storing your passwords on gitlab or somewhere you prefer"); println!("1. Run `mps init`");
println!("2. Create dir `mps`: `mkdir ~/mps`"); println!("2. Init `storage` under git:");
println!("3. Clone to your home folder `~/.mps/storage`: `git clone <your_storage_url> storage`"); println!(" cd storage");
println!("4. Export varable `$MPS_HOME`: `export MPS_HOME=\"/home/<your_username>/.mps\"`"); println!(" git init");
println!("5. Run `mps init`");
} }
fn prompt_new_password() -> io::Result<String> { fn prompt_new_password() -> io::Result<String> {

8
src/paths.rs

@ -9,10 +9,10 @@ pub static PATH_DB: &str = "db.mps";
pub fn get_storage_path() -> io::Result<String> { pub fn get_storage_path() -> io::Result<String> {
let mps_home = env::var(ENV_MPS_HOME).map_err(|err| { let result = match env::var(ENV_MPS_HOME) {
io::Error::new(io::ErrorKind::NotFound, format!("{} error: {}", ENV_MPS_HOME, err)) Ok(mps_home) => format!("{}/{}", mps_home, PATH_STORAGE),
})?; Err(_) => PATH_STORAGE.to_string()
let result = format!("{}/{}", mps_home, PATH_STORAGE); };
Ok(result) Ok(result)
} }

Loading…
Cancel
Save