From 734ab6f470f19861b7f93729adbad8b31348fc78 Mon Sep 17 00:00:00 2001 From: Noor Date: Fri, 4 Jul 2025 18:13:30 +0530 Subject: [PATCH] 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. --- src/config.rs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/config.rs b/src/config.rs index e35ff7f..d096800 100644 --- a/src/config.rs +++ b/src/config.rs @@ -196,13 +196,29 @@ impl Config { } fn config_path() -> Result { - 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 { - 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 {