···11# Safir
2233Repo containing the source for `safir` and `safir-mem`.
44+55+:warning: `safir-mem` and `safir-core` are NO LONGER MAINTAINED :warning:
66+77+They will stay part of the repo for backward usage but the `safir` project has been reworked and brought back to its roots.
88+Everything now lives in the `safir` project.
+7
safir-core/README.md
···11# Safir Core
2233+## Notice
44+55+:warning: This is now archived and no longer updated :warning:
66+77+It was ambitious (and worked kinda) but became far too unweildy and complicated when it didn't have to.
88+Maybe a rewrite in the future but for now, it's now archived.
99+310Internal library used by `safir` and `safir-mem` found [here](https://github.com/Tyrannican/safir)
411512Not intended for public use unless you want to contribute!
+7
safir-mem/README.md
···11# Safir-mem
2233+## Notice
44+55+:warning: This is now archived and no longer updated :warning:
66+77+It was ambitious (and worked kinda) but became far too unweildy and complicated when it didn't have to.
88+Maybe a rewrite in the future but for now, it's now archived.
99+310Simple in-memory CLI key/value store.
411512The in-memory version of [Safir](https://crates.io/crates/safir)!
+25
safir/CHANGELOG.md
···2233Documenting changes between versions beginning from v0.3.0
4455+## v0.9.0
66+77+**THIS IS A BREAKING CHANGE**
88+99+The entire `safir` project has been overhauled and brought back to it's original (and simple) purpose: display Key-value pairs.
1010+1111+When working on the whole project, it became clear to me that it was growing _way_ out of control.
1212+Initially it was to be an in-memory version (similar to Redis) but an on-disk storage solution was developed first.
1313+The in-memory version spawned a whole load of side-projects (`rubin` for one) but in doing so, it became an over-engineered beast.
1414+1515+At it's heart, `safir` was simply meant to be a small program to store key-value pairs and retrieve them later - that's it!
1616+So when I rewrote it in Go for fun, I realised that it was far too complex and could just be a simple command-line tool with simple commands.
1717+1818+So here we are, it's back to it's original "mindset" and is now _far_ simpler, just storing KV pairs on disk.
1919+No additional libraries, no in-memory versions; just a simple KV store.
2020+2121+The other versions are still available but are no longer maintained and this will be the "final" form going forward.
2222+2323+Sorry for any inconvenience and hope you enjoy the more simpler version!
2424+2525+* Overhauled project to be simpler with no crazy, custom-built backend solutions
2626+* No pretty output, just displays the KV in the format `[key]="[value]"`
2727+* No configs, just a JSON file stored at `$HOME/.safirstore/safirstore.json`
2828+* All previous commands still work as they did before (minus the additional ones for in-memory storage)
2929+530## v0.8.0
631732Headless mode!
+3-5
safir/Cargo.toml
···11[package]
22name = "safir"
33-version = "0.8.1"
33+version = "0.9.0"
44edition = "2021"
55authors = ["Graham Keenan graham.keenan@outlook.com"]
66license = "MIT OR Apache-2.0"
···1111keywords = ["cli", "terminal", "utility", "key-value", "store"]
1212categories = ["command-line-utilities"]
13131414-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1515-1614[dependencies]
1715clap = { version = "4.2.5" , features = ["derive"] }
1818-tokio = { version = "1.28.2", features = ["full"] }
1919-safir-core = { version = "0.2.2", path = "../safir-core" }
2016anyhow = "1.0.75"
1717+dirs = "5.0.1"
1818+serde_json = "1.0.108"
+69-9
safir/README.md
···2828Usage: safir <COMMAND>
29293030Commands:
3131- add Add a value to the store with the given key
3232- get Get a value from the store
3333- rm Remove values from the store
3434- alias Output the alias command for a key / value pair to be entered into a shell session
3535- export Output the export command for a key / value pair to be entered into a shell session
3636- clear Clear all keys/values from the store
3737- purge Purges the .safirstore directory, removing it and its contents
3838- headless Set the headless mode
3939- help Print this message or the help of the given subcommand(s)
3131+ add Add a value to the store with the given key
3232+ get Get values from the store
3333+ rm Remove values from the store
3434+ alias Output the alias command for key / value pairs
3535+ export Output the export command for a key / value pairs
3636+ list List all values in the store
3737+ clear Clear all keys/values from the store
3838+ purge Purges the .safirstore directory, removing it and its contents
3939+ help Print this message or the help of the given subcommand(s)
40404141Options:
4242 -h, --help Print help
4343 -V, --version Print version
4444```
45454646+## Examples
4747+4848+Adding a key and value to the store:
4949+5050+```bash
5151+safir add api_key "api_key_value"
5252+```
5353+5454+Retrieving a value from the store:
5555+5656+```bash
5757+safir get api_key
5858+# api_key="api_key_value"
5959+```
6060+6161+Removing a value from the store:
6262+6363+```bash
6464+safir rm api_key
6565+```
6666+6767+List all values in the store:
6868+6969+```bash
7070+safir list
7171+7272+# api_key="api_key_value"
7373+# another_api_key="another_value"
7474+```
7575+7676+Exporting a value:
7777+7878+```bash
7979+safir export api_key
8080+# export api_key="api_key_value"
8181+8282+$(safir export api_key) # <-- Will export the value to the current shell
8383+```
8484+8585+Aliasing a value:
8686+8787+```bash
8888+safir alias long_command
8989+# alias long_command="cd build/ && make && sudo make install"
9090+9191+$(safir alias long_command) # <-- Will alias the command in the current shell
9292+```
9393+9494+Clear the store:
9595+9696+```bash
9797+safir clear
9898+# Will remove all contents in the store
9999+```
100100+101101+Purge the store (remove EVERYTHING `safir` related)
102102+103103+```bash
104104+safir purge # Will remove the .safirstore directory
105105+```
+10-20
safir/src/cli.rs
···1818 /// Add a value to the store with the given key
1919 Add(AddArgs),
20202121- /// Get a value from the store
2121+ /// Get values from the store
2222 Get(GetArgs),
23232424 /// Remove values from the store
2525 Rm(RemoveArgs),
26262727- /// Output the alias command for a key / value pair to be entered into a shell session
2727+ /// Output the alias command for key / value pairs
2828 Alias(SetArgs),
29293030- /// Output the export command for a key / value pair to be entered into a shell session
3030+ /// Output the export command for a key / value pairs
3131 Export(SetArgs),
32323333+ /// List all values in the store
3434+ List,
3535+3336 /// Clear all keys/values from the store
3437 Clear,
35383639 /// Purges the .safirstore directory, removing it and its contents
3740 Purge,
3838-3939- /// Set the headless mode
4040- #[clap(subcommand)]
4141- Headless(HeadlessFlags),
4241}
43424443/// Arguments for adding a value to the store with a given key
···5150 pub value: String,
5251}
53525454-/// Arguments for retrieving a value from the store with a given key
5353+/// Arguments for retrieving values from the store with the given keys
5554#[derive(Args, Debug)]
5655pub struct GetArgs {
5757- /// Name of the value to retrieve from the store
5656+ /// Keys to retrieve the values for
5857 ///
5958 /// Returns nothing if the key does not exist
6060- pub key: Option<String>,
5959+ pub keys: Vec<String>,
6160}
62616362/// Arguments for removing values from the store with given keys
···6665 /// Name of the keys to remove from the store
6766 ///
6867 /// Does nothing if the keys do not exist
6969- pub key: Vec<String>,
6868+ pub keys: Vec<String>,
7069}
71707271/// Arguments for outputting commands with a given prefix
···7574 /// Name of the keys to display (e.g. alias / export)
7675 pub keys: Vec<String>,
7776}
7878-7979-#[derive(Subcommand, Debug)]
8080-pub enum HeadlessFlags {
8181- /// Set headless mode ON
8282- On,
8383-8484- /// Set headless mode OFF
8585- Off,
8686-}