From 6b6c7b23568ca4d21dc131abd3e2ccc080988176 Mon Sep 17 00:00:00 2001 From: Noor Date: Tue, 15 Jul 2025 19:57:42 +0530 Subject: [PATCH] custom CLI directory for detee-api specify a custom path for the CLI directory using the DETEE_API_USER_PATH environment variable. --- src/config.rs | 6 ++++-- src/constants.rs | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/config.rs b/src/config.rs index 5c55c86..b0190e7 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 -use crate::constants::{BRAIN_STAGING, BRAIN_TESTING}; +use crate::constants::{BRAIN_STAGING, BRAIN_TESTING, CONFIG_OVERRIDE_PATH_ENV}; use crate::general; use crate::utils::block_on; use ed25519_dalek::SigningKey; @@ -187,7 +187,9 @@ impl Config { } pub fn cli_dir_path() -> Result { - let dir = Self::home_dir() + ("/.detee/cli"); + let dir = std::env::var(CONFIG_OVERRIDE_PATH_ENV) + .unwrap_or_else(|_| Self::home_dir() + ("/.detee/cli")); + if !Path::new(&dir).exists() { warn!("Could not config dir. Creating {dir}"); std::fs::create_dir_all(dir.clone())?; diff --git a/src/constants.rs b/src/constants.rs index 828cb83..e7ceb52 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -5,6 +5,7 @@ use std::sync::LazyLock; pub const HRATLS_APP_PORT: u32 = 34500; pub const MAX_REDIRECTS: u16 = 3; +pub const CONFIG_OVERRIDE_PATH_ENV: &str = "DETEE_API_USER_PATH"; pub const STAGING_BRAIN_URLS: [&str; 3] = [ "https://156.146.63.216:31337", // staging brain 1 -- 2.43.0