From 7562192405728f0f525e7efd8a3c00cc059c6c13 Mon Sep 17 00:00:00 2001 From: JohanChane Date: Sun, 5 Jan 2025 20:54:48 +0800 Subject: [PATCH] Add `--config` for specifying clashtui config dir --- clashtui/src/app.rs | 3 +++ clashtui/src/main.rs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/clashtui/src/app.rs b/clashtui/src/app.rs index 18e58eda..6cae3d2f 100644 --- a/clashtui/src/app.rs +++ b/clashtui/src/app.rs @@ -27,6 +27,9 @@ pub struct CliEnv { /// print version information and exit #[argh(switch, short = 'v')] pub version: bool, + /// specify the ClashTUI config directory + #[argh(option, short = 'c', long = "config")] + pub config_dir: Option, } pub struct App { diff --git a/clashtui/src/main.rs b/clashtui/src/main.rs index 7af11073..40d27dad 100644 --- a/clashtui/src/main.rs +++ b/clashtui/src/main.rs @@ -31,7 +31,7 @@ fn main() { let mut flags = Flags::empty(); // ## Setup logging as early as possible. So We can log. - let config_dir = load_app_dir(&mut flags); + let config_dir = cli_env.config_dir.unwrap_or_else(|| load_app_dir(&mut flags)); setup_logging(config_dir.join("clashtui.log").to_str().unwrap()); let tick_rate = 250; // time in ms between two ticks.