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:
@@ -567,8 +567,9 @@ cargo run --features player --bin momentry_player -- -o
|
||||
### Paths
|
||||
- `MOMENTRY_OUTPUT_DIR` - Output directory (default: `/Users/accusys/momentry/output`)
|
||||
- `MOMENTRY_BACKUP_DIR` - Backup directory
|
||||
- `MOMENTRY_SCRIPTS_DIR` - Scripts directory (default: `/Users/accusys/momentry_core_0.1/tools/script`)
|
||||
- `MOMENTRY_CLI_DIR` - CLI tools directory (default: `/Users/accusys/momentry_core_0.1/tools/cli`)
|
||||
- `MOMENTRY_PYTHON_PATH` - Python path (default: `/opt/homebrew/bin/python3.11`)
|
||||
- `MOMENTRY_SCRIPTS_DIR` - Scripts directory
|
||||
|
||||
### Critical Variables for Startup Scripts
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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(|| {
|
||||
|
||||
+36
-13
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Tools Directory
|
||||
version: 1.0
|
||||
version: 1.1
|
||||
date: 2026-09-27
|
||||
author: OpenCode
|
||||
status: migrated
|
||||
@@ -125,6 +125,40 @@ cargo build --release
|
||||
./target/release/appearance
|
||||
```
|
||||
|
||||
## 環境變數配置
|
||||
|
||||
### 腳本路徑
|
||||
|
||||
```bash
|
||||
# Python 腳本路徑
|
||||
export MOMENTRY_SCRIPTS_DIR=/Users/accusys/momentry_core/tools/script
|
||||
|
||||
# CLI 工具路徑
|
||||
export MOMENTRY_CLI_DIR=/Users/accusys/momentry_core/tools/cli
|
||||
```
|
||||
|
||||
### 其他路徑
|
||||
|
||||
```bash
|
||||
# 輸出路徑
|
||||
export MOMENTRY_OUTPUT_DIR=/Users/accusys/momentry/output
|
||||
|
||||
# Python 路徑
|
||||
export MOMENTRY_PYTHON_PATH=/opt/homebrew/bin/python3.11
|
||||
```
|
||||
|
||||
## Rust 代碼中使用
|
||||
|
||||
```rust
|
||||
use crate::core::config::{SCRIPTS_DIR, CLI_DIR};
|
||||
|
||||
// 獲取腳本路徑
|
||||
let scripts_dir = SCRIPTS_DIR.as_str();
|
||||
|
||||
// 獲取 CLI 路徑
|
||||
let cli_dir = CLI_DIR.as_str();
|
||||
```
|
||||
|
||||
## 遷移說明
|
||||
|
||||
### 來源
|
||||
@@ -139,18 +173,7 @@ cargo build --release
|
||||
|
||||
新代碼建議使用 `tools/` 路徑。
|
||||
|
||||
## 配置
|
||||
|
||||
環境變數 `MOMENTRY_SCRIPTS_DIR` 需要更新:
|
||||
|
||||
```bash
|
||||
# 舊路徑
|
||||
export MOMENTRY_SCRIPTS_DIR=/Users/accusys/momentry_core/scripts
|
||||
|
||||
# 新路徑
|
||||
export MOMENTRY_SCRIPTS_DIR=/Users/accusys/momentry_core/tools/script
|
||||
```
|
||||
|
||||
## 相關文檔
|
||||
|
||||
- `/Users/accusys/momentry_core/docs_v1.0/DESIGN/Tools_Directory_Restructure.md`
|
||||
- `/Users/accusys/momentry_core/AGENTS.md` - 環境變數配置
|
||||
|
||||
Reference in New Issue
Block a user