feat: add MOMENTRY_CLI_DIR configuration

添加 CLI 工具路徑配置:
- admin_config.rs: 新增 cli_dir 字段和 get_cli_dir() 函數
- config.rs: 新增 CLI_DIR 常量
- 默認路徑: /Users/accusys/momentry_core_0.1/tools/cli

環境變數:
- MOMENTRY_SCRIPTS_DIR: Python 腳本路徑
- MOMENTRY_CLI_DIR: Swift/Rust CLI 工具路徑

文檔更新:
- tools/README.md: 環境變數配置說明
- AGENTS.md: 環境變數列表更新
This commit is contained in:
Accusys
2026-09-27 12:13:27 +08:00
parent af028ab8f4
commit 8ab6802bff
4 changed files with 55 additions and 16 deletions
+15 -2
View File
@@ -61,6 +61,8 @@ pub struct PathsConfig {
pub backup_dir: String,
#[serde(default = "default_scripts_dir")]
pub scripts_dir: String,
#[serde(default = "default_cli_dir")]
pub cli_dir: String,
#[serde(default = "default_python_path")]
pub python_path: String,
#[serde(default = "default_ffmpeg_path")]
@@ -79,7 +81,12 @@ fn default_backup_dir() -> String {
fn default_scripts_dir() -> String {
std::env::var("MOMENTRY_SCRIPTS_DIR")
.unwrap_or_else(|_| "/Users/accusys/momentry_core_0.1/scripts".to_string())
.unwrap_or_else(|_| "/Users/accusys/momentry_core_0.1/tools/script".to_string())
}
fn default_cli_dir() -> String {
std::env::var("MOMENTRY_CLI_DIR")
.unwrap_or_else(|_| "/Users/accusys/momentry_core_0.1/tools/cli".to_string())
}
fn default_python_path() -> String {
@@ -570,7 +577,9 @@ pub fn get_paths_sync() -> PathsConfig {
backup_dir: std::env::var("MOMENTRY_BACKUP_DIR")
.unwrap_or_else(|_| "/Users/accusys/momentry/backup/momentry".to_string()),
scripts_dir: std::env::var("MOMENTRY_SCRIPTS_DIR")
.unwrap_or_else(|_| "/Users/accusys/momentry_core_0.1/scripts".to_string()),
.unwrap_or_else(|_| "/Users/accusys/momentry_core_0.1/tools/script".to_string()),
cli_dir: std::env::var("MOMENTRY_CLI_DIR")
.unwrap_or_else(|_| "/Users/accusys/momentry_core_0.1/tools/cli".to_string()),
python_path: std::env::var("MOMENTRY_PYTHON_PATH")
.unwrap_or_else(|_| "/opt/homebrew/bin/python3.11".to_string()),
ffmpeg_path: std::env::var("MOMENTRY_FFMPEG").unwrap_or_else(|_| "ffmpeg".to_string()),
@@ -589,6 +598,10 @@ pub fn get_scripts_dir() -> String {
get_paths_sync().scripts_dir
}
pub fn get_cli_dir() -> String {
get_paths_sync().cli_dir
}
pub fn get_python_path() -> String {
get_paths_sync().python_path
}
+2
View File
@@ -197,6 +197,8 @@ pub static BACKUP_DIR: Lazy<String> = Lazy::new(|| crate::core::admin_config::ge
pub static SCRIPTS_DIR: Lazy<String> = Lazy::new(|| crate::core::admin_config::get_scripts_dir());
pub static CLI_DIR: Lazy<String> = Lazy::new(|| crate::core::admin_config::get_cli_dir());
pub static PYTHON_PATH: Lazy<String> = Lazy::new(|| crate::core::admin_config::get_python_path());
pub static MEDIA_BASE_URL: Lazy<String> = Lazy::new(|| {