Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add env command #18

Merged
merged 2 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Documenting changes between versions beginning from v0.3.0

## v0.10.1

* Added new command to display the currently loaded environment

## v0.10.0

* SQLite DB support
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "safir"
version = "0.10.0"
version = "0.10.1"
edition = "2021"
authors = ["Graham Keenan <[email protected]>"]
license = "MIT OR Apache-2.0"
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Commands:
clear Clear all keys/values from the store
purge Purges the .safirstore directory, removing it and its contents
use Use / create an environment to store key / value pairs
env Display the current loaded environment
help Print this message or the help of the given subcommand(s)

Options:
Expand Down Expand Up @@ -137,3 +138,9 @@ safir mode file # Switch to using a JSON file for storage

safir mode database # Switch to using an SQLite database for storage
```

Displaying the currently loaded environment:

```bash
safir env # Will display the currently loaded environment
```
3 changes: 3 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,7 @@ pub enum Commands {
#[arg(default_value_t = String::from("default"))]
environment: String,
},

/// Display the current loaded environment
Env,
}
5 changes: 5 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ async fn main() -> Result<()> {
cfg.write().context("writing config out")?;
println!("Using environment '{}'", environment);
}
Commands::Env => {
let cfg = safir.get_config();
let env = cfg.environment;
println!("Currently loaded environment: '{env}'");
}
}

Ok(())
Expand Down