custom config and key paths for detee-api

Allows to specify custom paths for the configuration file and wallet key by using the `DETEE_API_USER_PATH` environment variable.
This commit is contained in:
Noor 2025-07-04 18:13:30 +05:30
parent 97bd62153d
commit 734ab6f470
Signed by: noormohammedb
GPG Key ID: D83EFB8B3B967146

@ -196,13 +196,29 @@ impl Config {
}
fn config_path() -> Result<String, Error> {
let config_path = Self::cli_dir_path()? + ("/cli-config.yaml");
Ok(config_path)
match std::env::var("DETEE_API_USER_PATH") {
Ok(user_path) => {
let config_path = format!("{user_path}/cli-config.yaml");
Ok(config_path)
}
_ => {
let config_path = Self::cli_dir_path()? + ("/cli-config.yaml");
Ok(config_path)
}
}
}
fn detee_wallet_key_path() -> Result<String, Error> {
let config_path = Self::cli_dir_path()? + ("/secret_detee_wallet_key");
Ok(config_path)
match std::env::var("DETEE_API_USER_PATH") {
Ok(user_path) => {
let config_path = format!("{user_path}/secret_detee_wallet_key");
Ok(config_path)
}
_ => {
let config_path = Self::cli_dir_path()? + ("/secret_detee_wallet_key");
Ok(config_path)
}
}
}
fn load_config_from_file() -> Result<Self, Error> {