workflow-cli 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- workflow_cli-0.1.0/LICENSE +21 -0
- workflow_cli-0.1.0/MANIFEST.in +9 -0
- workflow_cli-0.1.0/PKG-INFO +108 -0
- workflow_cli-0.1.0/README.md +78 -0
- workflow_cli-0.1.0/pyproject.toml +46 -0
- workflow_cli-0.1.0/setup.cfg +4 -0
- workflow_cli-0.1.0/src/wfcli/__init__.py +3 -0
- workflow_cli-0.1.0/src/wfcli/commands/__init__.py +1 -0
- workflow_cli-0.1.0/src/wfcli/commands/config_cmd.py +45 -0
- workflow_cli-0.1.0/src/wfcli/commands/doc.py +149 -0
- workflow_cli-0.1.0/src/wfcli/commands/info.py +46 -0
- workflow_cli-0.1.0/src/wfcli/commands/sync.py +213 -0
- workflow_cli-0.1.0/src/wfcli/commands/workspace.py +368 -0
- workflow_cli-0.1.0/src/wfcli/config.py +162 -0
- workflow_cli-0.1.0/src/wfcli/core/__init__.py +1 -0
- workflow_cli-0.1.0/src/wfcli/core/docgen.py +219 -0
- workflow_cli-0.1.0/src/wfcli/core/naming.py +125 -0
- workflow_cli-0.1.0/src/wfcli/core/template.py +154 -0
- workflow_cli-0.1.0/src/wfcli/core/workspace.py +140 -0
- workflow_cli-0.1.0/src/wfcli/lark.py +260 -0
- workflow_cli-0.1.0/src/wfcli/main.py +29 -0
- workflow_cli-0.1.0/src/wfcli/updater.py +78 -0
- workflow_cli-0.1.0/src/wfcli/utils/__init__.py +1 -0
- workflow_cli-0.1.0/src/wfcli/utils/display.py +66 -0
- workflow_cli-0.1.0/src/wfcli/utils/fs.py +142 -0
- workflow_cli-0.1.0/src/workflow_cli.egg-info/SOURCES.txt +24 -0
- workflow_cli-0.1.0/tests/test_lark.py +116 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 wf-cli contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: workflow-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: 公司工作流 CLI 工具 —— 提升日常工作效率
|
|
5
|
+
Author-email: TODO <TODO@example.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/TODO/workflow-cli
|
|
8
|
+
Project-URL: Repository, https://github.com/TODO/workflow-cli
|
|
9
|
+
Project-URL: Issues, https://github.com/TODO/workflow-cli/issues
|
|
10
|
+
Keywords: cli,workflow,feishu,lark
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Utilities
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: click>=8.0
|
|
25
|
+
Requires-Dist: rich>=13.0
|
|
26
|
+
Provides-Extra: toml
|
|
27
|
+
Requires-Dist: tomli>=2.0; extra == "toml"
|
|
28
|
+
Requires-Dist: tomli-w>=1.0; extra == "toml"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# wf-cli
|
|
32
|
+
|
|
33
|
+
公司工作流 CLI 工具 —— 提升日常工作效率的命令行助手。
|
|
34
|
+
|
|
35
|
+
## 功能
|
|
36
|
+
|
|
37
|
+
| 命令 | 说明 |
|
|
38
|
+
|------|------|
|
|
39
|
+
| `wf-cli workspace` | 管理工作空间(创建/下载/新增文档类型/更新模板) |
|
|
40
|
+
| `wf-cli doc` | 基于模板交互式生成文档 |
|
|
41
|
+
| `wf-cli sync` | 与飞书云盘双向同步文件 |
|
|
42
|
+
| `wf-cli config` | 查看和修改 CLI 配置 |
|
|
43
|
+
| `wf-cli info` | 显示版本和当前工作环境状态 |
|
|
44
|
+
|
|
45
|
+
## 安装
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install workflow-cli
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 前置依赖
|
|
52
|
+
|
|
53
|
+
- **Python >= 3.10**
|
|
54
|
+
- **[lark-cli](https://www.npmjs.com/package/lark-cli)**(可选,飞书云盘集成需要):`npm install -g lark-cli`
|
|
55
|
+
|
|
56
|
+
> 💡 即使没有安装 lark-cli,`wf-cli info` 等命令仍可正常运行,仅飞书相关操作会友好提示。
|
|
57
|
+
|
|
58
|
+
## 快速开始
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# 查看帮助
|
|
62
|
+
wf-cli --help
|
|
63
|
+
|
|
64
|
+
# 查看当前状态
|
|
65
|
+
wf-cli info
|
|
66
|
+
|
|
67
|
+
# 查看默认配置
|
|
68
|
+
wf-cli config show
|
|
69
|
+
|
|
70
|
+
# 修改飞书根目录 token
|
|
71
|
+
wf-cli config set feishu.root_folder_token <your-token>
|
|
72
|
+
|
|
73
|
+
# 列出云盘上的工作空间
|
|
74
|
+
wf-cli workspace list
|
|
75
|
+
|
|
76
|
+
# 下载工作空间到本地
|
|
77
|
+
wf-cli workspace pull
|
|
78
|
+
|
|
79
|
+
# 生成文档
|
|
80
|
+
wf-cli doc generate
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## 配置
|
|
84
|
+
|
|
85
|
+
配置文件位于 `~/.wfcli/config.toml`(TOML 格式),首次运行时自动生成默认配置。
|
|
86
|
+
|
|
87
|
+
可配置项:
|
|
88
|
+
|
|
89
|
+
| 配置项 | 说明 | 默认值 |
|
|
90
|
+
|--------|------|--------|
|
|
91
|
+
| `feishu.root_folder_token` | 飞书云盘工作空间根目录 token | 已预设 |
|
|
92
|
+
| `workspace.default_local_dir` | 默认本地下载路径 | `~/workspaces` |
|
|
93
|
+
| `update.enabled` | 是否启用自动更新 | `true` |
|
|
94
|
+
| `update.check_interval_days` | 更新检查间隔(天) | `1` |
|
|
95
|
+
|
|
96
|
+
## Python 3.10 用户注意
|
|
97
|
+
|
|
98
|
+
Python 3.10 不内置 `tomllib`,请安装时带上 `toml` 额外依赖:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
pip install workflow-cli[toml]
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Python 3.11+ 用户无需额外操作。
|
|
105
|
+
|
|
106
|
+
## 许可证
|
|
107
|
+
|
|
108
|
+
MIT
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# wf-cli
|
|
2
|
+
|
|
3
|
+
公司工作流 CLI 工具 —— 提升日常工作效率的命令行助手。
|
|
4
|
+
|
|
5
|
+
## 功能
|
|
6
|
+
|
|
7
|
+
| 命令 | 说明 |
|
|
8
|
+
|------|------|
|
|
9
|
+
| `wf-cli workspace` | 管理工作空间(创建/下载/新增文档类型/更新模板) |
|
|
10
|
+
| `wf-cli doc` | 基于模板交互式生成文档 |
|
|
11
|
+
| `wf-cli sync` | 与飞书云盘双向同步文件 |
|
|
12
|
+
| `wf-cli config` | 查看和修改 CLI 配置 |
|
|
13
|
+
| `wf-cli info` | 显示版本和当前工作环境状态 |
|
|
14
|
+
|
|
15
|
+
## 安装
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install workflow-cli
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 前置依赖
|
|
22
|
+
|
|
23
|
+
- **Python >= 3.10**
|
|
24
|
+
- **[lark-cli](https://www.npmjs.com/package/lark-cli)**(可选,飞书云盘集成需要):`npm install -g lark-cli`
|
|
25
|
+
|
|
26
|
+
> 💡 即使没有安装 lark-cli,`wf-cli info` 等命令仍可正常运行,仅飞书相关操作会友好提示。
|
|
27
|
+
|
|
28
|
+
## 快速开始
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# 查看帮助
|
|
32
|
+
wf-cli --help
|
|
33
|
+
|
|
34
|
+
# 查看当前状态
|
|
35
|
+
wf-cli info
|
|
36
|
+
|
|
37
|
+
# 查看默认配置
|
|
38
|
+
wf-cli config show
|
|
39
|
+
|
|
40
|
+
# 修改飞书根目录 token
|
|
41
|
+
wf-cli config set feishu.root_folder_token <your-token>
|
|
42
|
+
|
|
43
|
+
# 列出云盘上的工作空间
|
|
44
|
+
wf-cli workspace list
|
|
45
|
+
|
|
46
|
+
# 下载工作空间到本地
|
|
47
|
+
wf-cli workspace pull
|
|
48
|
+
|
|
49
|
+
# 生成文档
|
|
50
|
+
wf-cli doc generate
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## 配置
|
|
54
|
+
|
|
55
|
+
配置文件位于 `~/.wfcli/config.toml`(TOML 格式),首次运行时自动生成默认配置。
|
|
56
|
+
|
|
57
|
+
可配置项:
|
|
58
|
+
|
|
59
|
+
| 配置项 | 说明 | 默认值 |
|
|
60
|
+
|--------|------|--------|
|
|
61
|
+
| `feishu.root_folder_token` | 飞书云盘工作空间根目录 token | 已预设 |
|
|
62
|
+
| `workspace.default_local_dir` | 默认本地下载路径 | `~/workspaces` |
|
|
63
|
+
| `update.enabled` | 是否启用自动更新 | `true` |
|
|
64
|
+
| `update.check_interval_days` | 更新检查间隔(天) | `1` |
|
|
65
|
+
|
|
66
|
+
## Python 3.10 用户注意
|
|
67
|
+
|
|
68
|
+
Python 3.10 不内置 `tomllib`,请安装时带上 `toml` 额外依赖:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pip install workflow-cli[toml]
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Python 3.11+ 用户无需额外操作。
|
|
75
|
+
|
|
76
|
+
## 许可证
|
|
77
|
+
|
|
78
|
+
MIT
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "workflow-cli"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "公司工作流 CLI 工具 —— 提升日常工作效率"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [
|
|
14
|
+
{name = "TODO", email = "TODO@example.com"},
|
|
15
|
+
]
|
|
16
|
+
keywords = ["cli", "workflow", "feishu", "lark"]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Development Status :: 3 - Alpha",
|
|
19
|
+
"Environment :: Console",
|
|
20
|
+
"Intended Audience :: Developers",
|
|
21
|
+
"Operating System :: OS Independent",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Programming Language :: Python :: 3.10",
|
|
24
|
+
"Programming Language :: Python :: 3.11",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
|
+
"Programming Language :: Python :: 3.13",
|
|
27
|
+
"Topic :: Utilities",
|
|
28
|
+
]
|
|
29
|
+
dependencies = [
|
|
30
|
+
"click>=8.0",
|
|
31
|
+
"rich>=13.0",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
[project.optional-dependencies]
|
|
35
|
+
toml = ["tomli>=2.0", "tomli-w>=1.0"]
|
|
36
|
+
|
|
37
|
+
[project.urls]
|
|
38
|
+
Homepage = "https://github.com/TODO/workflow-cli"
|
|
39
|
+
Repository = "https://github.com/TODO/workflow-cli"
|
|
40
|
+
Issues = "https://github.com/TODO/workflow-cli/issues"
|
|
41
|
+
|
|
42
|
+
[project.scripts]
|
|
43
|
+
wf-cli = "wfcli.main:cli"
|
|
44
|
+
|
|
45
|
+
[tool.setuptools.packages.find]
|
|
46
|
+
where = ["src"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""commands 子命令包"""
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""config 子命令 - 配置管理"""
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
|
|
5
|
+
from wfcli import config as cfg
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@click.group()
|
|
9
|
+
def config():
|
|
10
|
+
"""配置管理"""
|
|
11
|
+
pass
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@config.command()
|
|
15
|
+
def show():
|
|
16
|
+
"""查看当前配置"""
|
|
17
|
+
data = cfg.load_config()
|
|
18
|
+
_print_dict(data)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@config.command()
|
|
22
|
+
@click.argument("key")
|
|
23
|
+
@click.argument("value")
|
|
24
|
+
def set(key: str, value: str):
|
|
25
|
+
"""修改配置项,如: wfcli config set feishu.root_folder_token xxx"""
|
|
26
|
+
cfg.set_value(key, value)
|
|
27
|
+
click.echo(f"已更新: {key} = {value}")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@config.command()
|
|
31
|
+
def reset():
|
|
32
|
+
"""重置为默认配置"""
|
|
33
|
+
cfg.save_config(cfg.DEFAULT_CONFIG)
|
|
34
|
+
click.echo("已重置为默认配置")
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _print_dict(data: dict, indent: int = 0) -> None:
|
|
38
|
+
"""递归打印字典内容"""
|
|
39
|
+
prefix = " " * indent
|
|
40
|
+
for k, v in data.items():
|
|
41
|
+
if isinstance(v, dict):
|
|
42
|
+
click.echo(f"{prefix}[{k}]")
|
|
43
|
+
_print_dict(v, indent + 1)
|
|
44
|
+
else:
|
|
45
|
+
click.echo(f"{prefix}{k} = {v}")
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"""doc 子命令 - 文档生成"""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from datetime import datetime
|
|
6
|
+
|
|
7
|
+
import click
|
|
8
|
+
|
|
9
|
+
from wfcli.core.docgen import (
|
|
10
|
+
select_template,
|
|
11
|
+
collect_inputs,
|
|
12
|
+
generate_document,
|
|
13
|
+
check_and_save,
|
|
14
|
+
run_checklist,
|
|
15
|
+
)
|
|
16
|
+
from wfcli.core.template import load_template
|
|
17
|
+
from wfcli.core.naming import build_filename
|
|
18
|
+
from wfcli.utils.fs import require_workspace_root, parse_workspace_md
|
|
19
|
+
from wfcli.utils.display import print_success, print_error, print_info
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@click.group()
|
|
23
|
+
def doc():
|
|
24
|
+
"""文档生成"""
|
|
25
|
+
pass
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@doc.command()
|
|
29
|
+
@click.option("--type", "-t", "doc_type", default=None, help="文档类型(跳过交互式选择)")
|
|
30
|
+
@click.option("--topic", default=None, help="文档主题")
|
|
31
|
+
@click.option("--output", "-o", default=None, help="指定输出目录(相对于工作空间根目录)")
|
|
32
|
+
def generate(doc_type: str | None, topic: str | None, output: str | None):
|
|
33
|
+
"""按模板生成交档
|
|
34
|
+
|
|
35
|
+
交互式选择模板、填写内容,按命名规范保存到本地对应目录。
|
|
36
|
+
"""
|
|
37
|
+
ws_root = require_workspace_root()
|
|
38
|
+
ws_info = parse_workspace_md(ws_root / "WORKSPACE.md")
|
|
39
|
+
|
|
40
|
+
# 1. 选择模板
|
|
41
|
+
if doc_type:
|
|
42
|
+
from wfcli.core.template import list_templates
|
|
43
|
+
templates = list_templates(ws_root)
|
|
44
|
+
template_info = next(
|
|
45
|
+
(t for t in templates if doc_type in t["type"] or doc_type in t["name"]),
|
|
46
|
+
None,
|
|
47
|
+
)
|
|
48
|
+
if not template_info:
|
|
49
|
+
print_error(f"未找到匹配的文档类型: {doc_type}")
|
|
50
|
+
print_info("可用类型:")
|
|
51
|
+
for t in templates:
|
|
52
|
+
click.echo(f" - {t['type']}")
|
|
53
|
+
return
|
|
54
|
+
else:
|
|
55
|
+
template_info = select_template(ws_root)
|
|
56
|
+
|
|
57
|
+
print_info(f"使用模板: {template_info['name']}")
|
|
58
|
+
|
|
59
|
+
# 2. 加载模板
|
|
60
|
+
template_data = load_template(template_info["path"])
|
|
61
|
+
|
|
62
|
+
# 3. 收集用户输入
|
|
63
|
+
if not topic:
|
|
64
|
+
topic = click.prompt("文档主题")
|
|
65
|
+
|
|
66
|
+
inputs = collect_inputs(template_data)
|
|
67
|
+
|
|
68
|
+
# 4. 生成文档
|
|
69
|
+
print_info("生成文档...")
|
|
70
|
+
content = generate_document(
|
|
71
|
+
template_data=template_data,
|
|
72
|
+
inputs=inputs,
|
|
73
|
+
title=topic,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
# 5. 预览
|
|
77
|
+
click.echo("\n" + "─" * 50)
|
|
78
|
+
click.echo(content[:500])
|
|
79
|
+
if len(content) > 500:
|
|
80
|
+
click.echo(f"\n... (共 {len(content)} 字符)")
|
|
81
|
+
click.echo("─" * 50)
|
|
82
|
+
|
|
83
|
+
# 6. 自检
|
|
84
|
+
if not run_checklist(template_data):
|
|
85
|
+
if not click.confirm("\n自检未全部通过,是否仍要保存?", default=False):
|
|
86
|
+
return
|
|
87
|
+
|
|
88
|
+
# 7. 确定保存位置
|
|
89
|
+
if output:
|
|
90
|
+
target_dir = output
|
|
91
|
+
else:
|
|
92
|
+
# 根据模板类型推断存放目录
|
|
93
|
+
target_dir = _infer_target_dir(ws_root, template_info["type"])
|
|
94
|
+
|
|
95
|
+
# 8. 保存
|
|
96
|
+
saved_path = check_and_save(
|
|
97
|
+
content=content,
|
|
98
|
+
workspace_root=ws_root,
|
|
99
|
+
target_dir=target_dir,
|
|
100
|
+
topic=topic,
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
print_success(f"文档已保存: {saved_path.relative_to(ws_root)}")
|
|
104
|
+
print_info(f"完整路径: {saved_path}")
|
|
105
|
+
print_info("提交到云盘: wfcli sync push " + str(saved_path))
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
@doc.command()
|
|
109
|
+
def list():
|
|
110
|
+
"""列出当前工作空间的可用文档类型"""
|
|
111
|
+
ws_root = require_workspace_root()
|
|
112
|
+
|
|
113
|
+
from wfcli.core.template import list_templates
|
|
114
|
+
templates = list_templates(ws_root)
|
|
115
|
+
|
|
116
|
+
if not templates:
|
|
117
|
+
print_info("当前工作空间没有可用模板")
|
|
118
|
+
return
|
|
119
|
+
|
|
120
|
+
print_info(f"工作空间: {ws_root.name}")
|
|
121
|
+
click.echo()
|
|
122
|
+
for t in templates:
|
|
123
|
+
click.echo(f" - {t['type']} ({t['name']}.md)")
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def _infer_target_dir(ws_root: Path, doc_type: str) -> str:
|
|
127
|
+
"""根据文档类型推断存放目录
|
|
128
|
+
|
|
129
|
+
从 WORKSPACE.md 的模板索引表中查找,找不到则用类型名作为目录名。
|
|
130
|
+
"""
|
|
131
|
+
ws_info = parse_workspace_md(ws_root / "WORKSPACE.md")
|
|
132
|
+
templates_map = ws_info.get("templates", {})
|
|
133
|
+
|
|
134
|
+
# 在模板索引中查找
|
|
135
|
+
for dtype, tpath in templates_map.items():
|
|
136
|
+
if doc_type in dtype:
|
|
137
|
+
# 从模板路径推断存放目录
|
|
138
|
+
# 模板路径如 "00_模板/01_01_会议纪要模板.md"
|
|
139
|
+
# 存放目录如 "01_会议纪要"
|
|
140
|
+
for d in (ws_root).iterdir():
|
|
141
|
+
if d.is_dir() and doc_type in d.name:
|
|
142
|
+
return d.name
|
|
143
|
+
|
|
144
|
+
# 兜底:查找包含类型名的目录
|
|
145
|
+
for d in ws_root.iterdir():
|
|
146
|
+
if d.is_dir() and doc_type in d.name:
|
|
147
|
+
return d.name
|
|
148
|
+
|
|
149
|
+
return doc_type
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""info 子命令 - 版本和状态信息"""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
import click
|
|
7
|
+
|
|
8
|
+
from wfcli import __version__
|
|
9
|
+
from wfcli import config as cfg
|
|
10
|
+
from wfcli.utils.fs import find_workspace_root
|
|
11
|
+
from wfcli.utils.display import print_info, print_success
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@click.command()
|
|
15
|
+
def info():
|
|
16
|
+
"""显示版本和当前工作状态"""
|
|
17
|
+
click.echo(f"wfcli v{__version__}")
|
|
18
|
+
click.echo(f"Python {sys.version.split()[0]}")
|
|
19
|
+
click.echo(f"配置文件: {cfg.CONFIG_FILE}")
|
|
20
|
+
|
|
21
|
+
if cfg.CONFIG_FILE.exists():
|
|
22
|
+
print_success("配置文件已就绪")
|
|
23
|
+
else:
|
|
24
|
+
print_info("配置文件不存在,将使用默认配置")
|
|
25
|
+
|
|
26
|
+
# 当前工作空间
|
|
27
|
+
ws_root = find_workspace_root()
|
|
28
|
+
if ws_root:
|
|
29
|
+
print_info(f"当前工作空间: {ws_root.name} ({ws_root})")
|
|
30
|
+
else:
|
|
31
|
+
print_info("当前不在任何工作空间中")
|
|
32
|
+
|
|
33
|
+
# lark-cli 检测
|
|
34
|
+
import subprocess
|
|
35
|
+
try:
|
|
36
|
+
result = subprocess.run(
|
|
37
|
+
["lark-cli", "--version"],
|
|
38
|
+
capture_output=True, text=True, timeout=5,
|
|
39
|
+
)
|
|
40
|
+
if result.returncode == 0:
|
|
41
|
+
ver = result.stdout.strip().split("\n")[0]
|
|
42
|
+
print_info(f"lark-cli: {ver}")
|
|
43
|
+
else:
|
|
44
|
+
print_info("lark-cli: 未检测到")
|
|
45
|
+
except (FileNotFoundError, subprocess.TimeoutExpired):
|
|
46
|
+
print_info("lark-cli: 未安装或不可用")
|