feat: load dotenv
This commit is contained in:
parent
f12de31125
commit
cb225ae7de
3 changed files with 18 additions and 1 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -260,6 +260,12 @@ version = "0.8.7"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
|
||||
|
||||
[[package]]
|
||||
name = "dotenv"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
|
||||
|
||||
[[package]]
|
||||
name = "dyn-clone"
|
||||
version = "1.0.17"
|
||||
|
@ -820,6 +826,7 @@ dependencies = [
|
|||
"base64",
|
||||
"chrono",
|
||||
"clap",
|
||||
"dotenv",
|
||||
"http",
|
||||
"indexmap",
|
||||
"jaq-interpret",
|
||||
|
|
|
@ -13,6 +13,7 @@ edition = "2021"
|
|||
base64 = "0.22.1"
|
||||
chrono = "0.4"
|
||||
clap = { version = "4.5", features = ["derive"] }
|
||||
dotenv = "0.15"
|
||||
http = "1.1.0"
|
||||
indexmap = { version = "2.6", features = ["serde"] }
|
||||
jaq-interpret = "1.5"
|
||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -23,6 +23,10 @@ struct PostWomanArgs {
|
|||
#[arg(short, long, default_value = "postwoman.toml")]
|
||||
collection: std::path::PathBuf,
|
||||
|
||||
/// environment (.env) to load
|
||||
#[arg(short, long, default_value = "")]
|
||||
env: String,
|
||||
|
||||
/// action to run
|
||||
#[clap(subcommand)]
|
||||
action: Option<PostWomanActions>,
|
||||
|
@ -86,6 +90,12 @@ fn main() {
|
|||
},
|
||||
|
||||
PostWomanActions::Run { query, parallel, debug, dry_run } => {
|
||||
eprintln!("~@ {APP_USER_AGENT}");
|
||||
|
||||
if let Err(e) = dotenv::from_filename(format!("{}.env", args.env)) {
|
||||
eprintln!(" ! error loading env file: {e}");
|
||||
}
|
||||
|
||||
// note that if you remove this test, there's another .expect() below you need to manage too!
|
||||
let filter = match regex::Regex::new(query) {
|
||||
Ok(regex) => regex,
|
||||
|
@ -114,7 +124,6 @@ fn main() {
|
|||
}
|
||||
};
|
||||
|
||||
eprintln!("~@ {APP_USER_AGENT}");
|
||||
if multi_thread {
|
||||
tokio::runtime::Builder::new_multi_thread()
|
||||
.enable_all()
|
||||
|
|
Loading…
Reference in a new issue