整理 tjwater-cli 代码和文档
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
# TJWater CLI
|
||||
|
||||
独立于服务端主代码的 Python CLI 文件夹,放在 `TJWaterServerBinary/cli/` 下,供 agent 服务器**直接调用并通过 stdout/stderr 参与管道**。
|
||||
|
||||
## 直接使用
|
||||
|
||||
```bash
|
||||
cd TJWaterServerBinary/cli
|
||||
./tjwater help --json
|
||||
```
|
||||
|
||||
这个入口文件可以直接参与管道:
|
||||
|
||||
```bash
|
||||
./tjwater help --json | jq
|
||||
```
|
||||
|
||||
它会优先使用:
|
||||
1. `cli/.venv/bin/python`
|
||||
2. 环境变量 `PYTHON`
|
||||
3. 当前环境里的 `python`
|
||||
4. 最后回退到 `python3`
|
||||
|
||||
如果需要,也可以显式走 Python:
|
||||
|
||||
```bash
|
||||
python -m tjwater_agent_cli help --json
|
||||
```
|
||||
|
||||
## 部署到 agent 服务器
|
||||
|
||||
最简单的方式是把整个 `TJWaterServerBinary/cli/` 文件夹同步到 agent 服务器,然后直接执行:
|
||||
|
||||
```bash
|
||||
cd TJWaterServerBinary/cli
|
||||
./tjwater help --json
|
||||
```
|
||||
|
||||
如果希望放到 PATH 中:
|
||||
|
||||
```bash
|
||||
chmod +x tjwater
|
||||
ln -s /path/to/TJWaterServerBinary/cli/tjwater /usr/local/bin/tjwater
|
||||
tjwater help --json
|
||||
```
|
||||
|
||||
## Python 依赖
|
||||
|
||||
```bash
|
||||
cd TJWaterServerBinary/cli
|
||||
python -m pip install -r requirements.txt
|
||||
```
|
||||
|
||||
只保留运行 CLI 必需依赖,不再包含安装包构建相关内容。
|
||||
|
||||
## 认证上下文
|
||||
|
||||
CLI 通过 `--auth-context` 读取 JSON 文件。常用字段:
|
||||
|
||||
```json
|
||||
{
|
||||
"server": "http://backend-host:8000",
|
||||
"access_token": "...",
|
||||
"project_id": "...",
|
||||
"network": "...",
|
||||
"username": "..."
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user