ChatCDN 0.1.2__tar.gz → 0.1.3__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.
Files changed (37) hide show
  1. {chatcdn-0.1.2 → chatcdn-0.1.3}/.github/workflows/ci.yml +1 -0
  2. {chatcdn-0.1.2 → chatcdn-0.1.3}/CHANGELOG.md +8 -0
  3. {chatcdn-0.1.2 → chatcdn-0.1.3}/DEVELOP.md +2 -1
  4. {chatcdn-0.1.2 → chatcdn-0.1.3}/PKG-INFO +6 -4
  5. {chatcdn-0.1.2 → chatcdn-0.1.3}/README.en.md +3 -1
  6. {chatcdn-0.1.2 → chatcdn-0.1.3}/README.md +3 -1
  7. {chatcdn-0.1.2 → chatcdn-0.1.3}/docs/capability-map.en.md +2 -2
  8. {chatcdn-0.1.2 → chatcdn-0.1.3}/docs/capability-map.md +2 -2
  9. {chatcdn-0.1.2 → chatcdn-0.1.3}/docs/cli-tree.en.md +9 -7
  10. {chatcdn-0.1.2 → chatcdn-0.1.3}/docs/cli-tree.md +9 -7
  11. {chatcdn-0.1.2 → chatcdn-0.1.3}/docs/interface-tree.md +1 -1
  12. {chatcdn-0.1.2 → chatcdn-0.1.3}/pyproject.toml +1 -1
  13. {chatcdn-0.1.2 → chatcdn-0.1.3}/src/ChatCDN.egg-info/PKG-INFO +6 -4
  14. {chatcdn-0.1.2 → chatcdn-0.1.3}/src/ChatCDN.egg-info/requires.txt +2 -2
  15. {chatcdn-0.1.2 → chatcdn-0.1.3}/src/chatcdn/__init__.py +1 -1
  16. chatcdn-0.1.3/src/chatcdn/cli.py +24 -0
  17. chatcdn-0.1.3/tests/test_cli.py +63 -0
  18. {chatcdn-0.1.2 → chatcdn-0.1.3}/tests/test_docs_contract.py +4 -0
  19. {chatcdn-0.1.2 → chatcdn-0.1.3}/tests/test_version.py +1 -1
  20. {chatcdn-0.1.2 → chatcdn-0.1.3}/tests/test_workflow_contract.py +1 -0
  21. chatcdn-0.1.2/src/chatcdn/cli.py +0 -119
  22. chatcdn-0.1.2/tests/test_cli.py +0 -37
  23. {chatcdn-0.1.2 → chatcdn-0.1.3}/.github/workflows/deploy.yaml +0 -0
  24. {chatcdn-0.1.2 → chatcdn-0.1.3}/.github/workflows/preview.yaml +0 -0
  25. {chatcdn-0.1.2 → chatcdn-0.1.3}/.github/workflows/publish.yml +0 -0
  26. {chatcdn-0.1.2 → chatcdn-0.1.3}/AGENTS.md +0 -0
  27. {chatcdn-0.1.2 → chatcdn-0.1.3}/LICENSE +0 -0
  28. {chatcdn-0.1.2 → chatcdn-0.1.3}/MANIFEST.in +0 -0
  29. {chatcdn-0.1.2 → chatcdn-0.1.3}/docs/index.en.md +0 -0
  30. {chatcdn-0.1.2 → chatcdn-0.1.3}/docs/index.md +0 -0
  31. {chatcdn-0.1.2 → chatcdn-0.1.3}/mkdocs.yml +0 -0
  32. {chatcdn-0.1.2 → chatcdn-0.1.3}/setup.cfg +0 -0
  33. {chatcdn-0.1.2 → chatcdn-0.1.3}/src/ChatCDN.egg-info/SOURCES.txt +0 -0
  34. {chatcdn-0.1.2 → chatcdn-0.1.3}/src/ChatCDN.egg-info/dependency_links.txt +0 -0
  35. {chatcdn-0.1.2 → chatcdn-0.1.3}/src/ChatCDN.egg-info/entry_points.txt +0 -0
  36. {chatcdn-0.1.2 → chatcdn-0.1.3}/src/ChatCDN.egg-info/top_level.txt +0 -0
  37. {chatcdn-0.1.2 → chatcdn-0.1.3}/src/chatcdn/config.py +0 -0
@@ -32,6 +32,7 @@ jobs:
32
32
  run: |
33
33
  chatcdn --version
34
34
  chatcdn --tree
35
+ chatcdn --tree-brief
35
36
  - name: Build distributions
36
37
  run: python -m build
37
38
  - name: Check distributions
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.3 - 2026-08-21
4
+
5
+ ### Changed
6
+
7
+ - Migrate the top-level Click tree to ChatStyle's shared `add_tree_option()` runtime, with signatures in `--tree` and compact output in `--tree-brief`.
8
+ - Raise the shared runtime bounds to `chatstyle>=0.2.0,<0.3.0` and `chatenv>=0.2.10,<0.3.0`.
9
+ - Extend CLI tests, documentation, and installed smoke checks to cover both tree modes and the public `chatcdn` root.
10
+
3
11
  ## 0.1.2 - 2026-08-12
4
12
 
5
13
  ### Changed
@@ -2,7 +2,8 @@
2
2
 
3
3
  ## CLI Rules
4
4
 
5
- - Use `chatstyle>=0.1.1,<0.2.0` and `chatenv>=0.2.3,<0.3.0` as the canonical CLI interaction runtime.
5
+ - Use `chatstyle>=0.2.0,<0.3.0` and `chatenv>=0.2.10,<0.3.0` as the canonical CLI interaction runtime.
6
+ - Attach ChatStyle's `add_tree_option()` to the top-level Click group. Keep parameter signatures in `--tree` and omit them only in `--tree-brief`.
6
7
  - Prefer `CommandSchema`, `CommandField`, `add_interactive_option()`, and `resolve_command_inputs()` for new commands.
7
8
  - Missing required args should auto-enter interactive mode when recoverable.
8
9
  - `-i` forces interactive mode; `-I` disables prompting and must fail fast.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ChatCDN
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: ChatArch CDN tooling package.
5
5
  Author-email: ChatArch <rex@chatarch.org>
6
6
  License-Expression: MIT
@@ -14,8 +14,8 @@ Requires-Python: >=3.10
14
14
  Description-Content-Type: text/markdown
15
15
  License-File: LICENSE
16
16
  Requires-Dist: click<9.0,>=8.1
17
- Requires-Dist: chatstyle<0.2.0,>=0.1.1
18
- Requires-Dist: chatenv<0.3.0,>=0.2.3
17
+ Requires-Dist: chatstyle<0.3.0,>=0.2.0
18
+ Requires-Dist: chatenv<0.3.0,>=0.2.10
19
19
  Provides-Extra: dev
20
20
  Requires-Dist: build; extra == "dev"
21
21
  Requires-Dist: pytest; extra == "dev"
@@ -66,14 +66,16 @@ pip install -e ".[dev]"
66
66
  chatcdn --help
67
67
  chatcdn --version
68
68
  chatcdn --tree
69
+ chatcdn --tree-brief
69
70
  python -m pytest -q
70
71
  python -m build
71
72
  ```
72
73
 
73
74
  ## 命令行规范
74
75
 
75
- 这个模板默认依赖 `chatstyle>=0.1.1,<0.2.0` 和 `chatenv>=0.2.3,<0.3.0`,新增命令应优先使用:
76
+ 这个模板默认依赖 `chatstyle>=0.2.0,<0.3.0` 和 `chatenv>=0.2.10,<0.3.0`,新增命令应优先使用:
76
77
 
78
+ - `add_tree_option()` 提供共享 Click 命令树;`--tree` 默认显示参数签名,`--tree-brief` 保留命令与说明但省略参数签名。
77
79
  - `CommandSchema` / `CommandField` 描述输入。
78
80
  - `add_interactive_option()` 提供统一 `-i/-I`。
79
81
  - `resolve_command_inputs()` 统一缺参补问、默认值、TTY 与校验。
@@ -37,14 +37,16 @@ pip install -e ".[dev]"
37
37
  chatcdn --help
38
38
  chatcdn --version
39
39
  chatcdn --tree
40
+ chatcdn --tree-brief
40
41
  python -m pytest -q
41
42
  python -m build
42
43
  ```
43
44
 
44
45
  ## CLI Contract
45
46
 
46
- This template depends on `chatstyle>=0.1.1,<0.2.0` and `chatenv>=0.2.3,<0.3.0`. New commands should prefer:
47
+ This template depends on `chatstyle>=0.2.0,<0.3.0` and `chatenv>=0.2.10,<0.3.0`. New commands should prefer:
47
48
 
49
+ - `add_tree_option()` for the shared Click command tree; `--tree` includes parameter signatures by default, while `--tree-brief` keeps command nodes and descriptions without signatures.
48
50
  - `CommandSchema` / `CommandField` for inputs.
49
51
  - `add_interactive_option()` for the shared `-i/-I` switch.
50
52
  - `resolve_command_inputs()` for missing args, defaults, TTY behavior, and validation.
@@ -37,14 +37,16 @@ pip install -e ".[dev]"
37
37
  chatcdn --help
38
38
  chatcdn --version
39
39
  chatcdn --tree
40
+ chatcdn --tree-brief
40
41
  python -m pytest -q
41
42
  python -m build
42
43
  ```
43
44
 
44
45
  ## 命令行规范
45
46
 
46
- 这个模板默认依赖 `chatstyle>=0.1.1,<0.2.0` 和 `chatenv>=0.2.3,<0.3.0`,新增命令应优先使用:
47
+ 这个模板默认依赖 `chatstyle>=0.2.0,<0.3.0` 和 `chatenv>=0.2.10,<0.3.0`,新增命令应优先使用:
47
48
 
49
+ - `add_tree_option()` 提供共享 Click 命令树;`--tree` 默认显示参数签名,`--tree-brief` 保留命令与说明但省略参数签名。
48
50
  - `CommandSchema` / `CommandField` 描述输入。
49
51
  - `add_interactive_option()` 提供统一 `-i/-I`。
50
52
  - `resolve_command_inputs()` 统一缺参补问、默认值、TTY 与校验。
@@ -8,7 +8,7 @@ Use this page to check which first-class capabilities `ChatCDN` currently owns,
8
8
 
9
9
  - **CLI Entry**
10
10
 
11
- `chatcdn --help`, `chatcdn --version`, and `chatcdn --tree` are the default verification entry points.
11
+ `chatcdn --help`, `chatcdn --version`, `chatcdn --tree`, and `chatcdn --tree-brief` are the default verification entry points.
12
12
 
13
13
  - **Python API**
14
14
 
@@ -24,7 +24,7 @@ Use this page to check which first-class capabilities `ChatCDN` currently owns,
24
24
 
25
25
  | Capability | Status | Notes |
26
26
  | --- | --- | --- |
27
- | CLI base entry | Implemented | The Click group exposes `--help`, `--version`, `--tree`, and base tests. |
27
+ | CLI base entry | Implemented | The Click group uses ChatStyle's shared tree runtime to expose `--help`, `--version`, `--tree`, `--tree-brief`, and base tests. |
28
28
  | ChatEnv provider | Implemented | The template generates `config.py` and a `chatenv.configs` entry point. |
29
29
  | Business commands | Not implemented | Add these from the real package domain; do not fake future commands in the template. |
30
30
 
@@ -8,7 +8,7 @@
8
8
 
9
9
  - **命令行入口**
10
10
 
11
- `chatcdn --help`、`chatcdn --version` 和 `chatcdn --tree` 是默认可验证入口。
11
+ `chatcdn --help`、`chatcdn --version`、`chatcdn --tree` 和 `chatcdn --tree-brief` 是默认可验证入口。
12
12
 
13
13
  - **Python 接口**
14
14
 
@@ -24,7 +24,7 @@
24
24
 
25
25
  | 能力 | 状态 | 说明 |
26
26
  | --- | --- | --- |
27
- | 命令行基础入口 | 已实现 | Click group 提供 `--help`、`--version`、`--tree` 和基础测试。 |
27
+ | 命令行基础入口 | 已实现 | Click group 通过 ChatStyle 共享树运行时提供 `--help`、`--version`、`--tree`、`--tree-brief` 和基础测试。 |
28
28
  | ChatEnv 配置提供者 | 已实现 | 默认生成 `config.py` 和 `chatenv.configs` 入口点。 |
29
29
  | 业务命令 | 未实现 | 按当前包真实需求补充,不能在模板里伪造未来命令。 |
30
30
 
@@ -1,16 +1,17 @@
1
1
  # CLI Capability Map
2
2
 
3
- This page is the compact capability map for the `ChatCDN` CLI. Keep the documented command tree aligned with the runtime `chatcdn --tree` output; do not present unimplemented commands as available operations.
3
+ This page is the compact capability map for the `ChatCDN` CLI. Keep the documented command tree aligned with the runtime `chatcdn --tree` and `chatcdn --tree-brief` output; do not present unimplemented commands as available operations.
4
4
 
5
5
  Importable Python functions are mapped in [Interface Tree](interface-tree.md). Current package boundaries are tracked in [Capability Map](capability-map.md).
6
6
 
7
7
  ## Top-Level Commands
8
8
 
9
9
  ```text
10
- chatcdn # ChatCDN command-line interface.
11
- ├── --help # Show this help message.
12
- ├── --version # Show the installed package version.
13
- └── --tree # Print the registered command tree.
10
+ chatcdn
11
+ ├── --help # Show this message and exit.
12
+ ├── --version # Show the version and exit.
13
+ ├── --tree # Print the registered CLI tree and exit.
14
+ └── --tree-brief # Print the registered CLI tree without parameter signatures and exit.
14
15
  ```
15
16
 
16
17
  ## Base Entries
@@ -18,10 +19,11 @@ chatcdn # ChatCDN command-line interface.
18
19
  ```text
19
20
  chatcdn --help # Verify the command is installed and inspect help
20
21
  chatcdn --version # Verify the installed version
21
- chatcdn --tree # Print the command tree from the real Click registry
22
+ chatcdn --tree # Print the shared Click registry tree with command signatures
23
+ chatcdn --tree-brief # Keep command nodes and descriptions but omit signatures
22
24
  ```
23
25
 
24
- `ChatCDN` currently has no business subcommands. After adding business commands, follow the ChatTea CLI tree pattern: split command groups into their own sections and annotate every command line.
26
+ The command tree is generated by ChatStyle's shared `add_tree_option()` runtime, with the public root fixed to `chatcdn`. `ChatCDN` currently has no parameterized business subcommands, so the existing node labels are the same in both modes; after such commands are added, `--tree` shows their signatures and `--tree-brief` omits them.
25
27
 
26
28
  ## Business Command Slots
27
29
 
@@ -1,16 +1,17 @@
1
1
  # CLI 能力地图
2
2
 
3
- 这篇文档是 `ChatCDN` CLI 的简明能力地图,用来校对哪些命令已经是一等入口、哪些仍然只是边界或规划。文档中的命令树应与 `chatcdn --tree` 的运行结果保持一致;不要把未实现命令写成已可用操作。
3
+ 这篇文档是 `ChatCDN` CLI 的简明能力地图,用来校对哪些命令已经是一等入口、哪些仍然只是边界或规划。文档中的命令树应与 `chatcdn --tree` 和 `chatcdn --tree-brief` 的运行结果保持一致;不要把未实现命令写成已可用操作。
4
4
 
5
5
  可导入 Python 函数映射见 [接口树](interface-tree.md)。当前包能力边界见 [能力地图](capability-map.md)。
6
6
 
7
7
  ## 顶层命令
8
8
 
9
9
  ```text
10
- chatcdn # ChatCDN command-line interface.
11
- ├── --help # Show this help message.
12
- ├── --version # Show the installed package version.
13
- └── --tree # Print the registered command tree.
10
+ chatcdn
11
+ ├── --help # Show this message and exit.
12
+ ├── --version # Show the version and exit.
13
+ ├── --tree # Print the registered CLI tree and exit.
14
+ └── --tree-brief # Print the registered CLI tree without parameter signatures and exit.
14
15
  ```
15
16
 
16
17
  ## 基础入口
@@ -18,10 +19,11 @@ chatcdn # ChatCDN command-line interface.
18
19
  ```text
19
20
  chatcdn --help # 验证命令已安装,并查看帮助
20
21
  chatcdn --version # 验证当前安装版本
21
- chatcdn --tree # 从真实 Click 注册树输出命令树
22
+ chatcdn --tree # 输出共享 Click 注册树,命令节点默认包含参数签名
23
+ chatcdn --tree-brief # 保留命令节点与说明,但省略参数签名
22
24
  ```
23
25
 
24
- 当前 `ChatCDN` 还没有业务子命令。新增业务命令后,应像 ChatTea 的 CLI 树一样,把命令组单独展开,并给每个命令写一行注释。
26
+ 命令树由 ChatStyle 的共享 `add_tree_option()` 运行时生成,公开根名固定为 `chatcdn`。当前 `ChatCDN` 还没有带参数的业务子命令,因此两种模式的现有节点标签相同;新增带参数命令后,`--tree` 会显示签名,`--tree-brief` 会省略签名。
25
27
 
26
28
  ## 业务命令槽位
27
29
 
@@ -12,7 +12,7 @@ from chatcdn import __version__
12
12
 
13
13
  ```text
14
14
  chatcdn
15
- ├── cli.py # Click 入口和真实注册树渲染,只做参数解析和输出
15
+ ├── cli.py # Click 入口和 ChatStyle 共享注册树接线,只做参数解析和输出
16
16
  └── <service>.py # 放包的核心可调用能力
17
17
  ```
18
18
 
@@ -9,7 +9,7 @@ description = "ChatArch CDN tooling package."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
11
11
  license = "MIT"
12
- dependencies = ["click>=8.1,<9.0", "chatstyle>=0.1.1,<0.2.0", "chatenv>=0.2.3,<0.3.0"]
12
+ dependencies = ["click>=8.1,<9.0", "chatstyle>=0.2.0,<0.3.0", "chatenv>=0.2.10,<0.3.0"]
13
13
  authors = [{name = "ChatArch", email = "rex@chatarch.org"}]
14
14
  keywords = ["chatcdn", "chatarch", "cli"]
15
15
  classifiers = [
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ChatCDN
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: ChatArch CDN tooling package.
5
5
  Author-email: ChatArch <rex@chatarch.org>
6
6
  License-Expression: MIT
@@ -14,8 +14,8 @@ Requires-Python: >=3.10
14
14
  Description-Content-Type: text/markdown
15
15
  License-File: LICENSE
16
16
  Requires-Dist: click<9.0,>=8.1
17
- Requires-Dist: chatstyle<0.2.0,>=0.1.1
18
- Requires-Dist: chatenv<0.3.0,>=0.2.3
17
+ Requires-Dist: chatstyle<0.3.0,>=0.2.0
18
+ Requires-Dist: chatenv<0.3.0,>=0.2.10
19
19
  Provides-Extra: dev
20
20
  Requires-Dist: build; extra == "dev"
21
21
  Requires-Dist: pytest; extra == "dev"
@@ -66,14 +66,16 @@ pip install -e ".[dev]"
66
66
  chatcdn --help
67
67
  chatcdn --version
68
68
  chatcdn --tree
69
+ chatcdn --tree-brief
69
70
  python -m pytest -q
70
71
  python -m build
71
72
  ```
72
73
 
73
74
  ## 命令行规范
74
75
 
75
- 这个模板默认依赖 `chatstyle>=0.1.1,<0.2.0` 和 `chatenv>=0.2.3,<0.3.0`,新增命令应优先使用:
76
+ 这个模板默认依赖 `chatstyle>=0.2.0,<0.3.0` 和 `chatenv>=0.2.10,<0.3.0`,新增命令应优先使用:
76
77
 
78
+ - `add_tree_option()` 提供共享 Click 命令树;`--tree` 默认显示参数签名,`--tree-brief` 保留命令与说明但省略参数签名。
77
79
  - `CommandSchema` / `CommandField` 描述输入。
78
80
  - `add_interactive_option()` 提供统一 `-i/-I`。
79
81
  - `resolve_command_inputs()` 统一缺参补问、默认值、TTY 与校验。
@@ -1,6 +1,6 @@
1
1
  click<9.0,>=8.1
2
- chatstyle<0.2.0,>=0.1.1
3
- chatenv<0.3.0,>=0.2.3
2
+ chatstyle<0.3.0,>=0.2.0
3
+ chatenv<0.3.0,>=0.2.10
4
4
 
5
5
  [dev]
6
6
  build
@@ -2,4 +2,4 @@
2
2
 
3
3
  __all__ = ["__version__"]
4
4
 
5
- __version__ = "0.1.2"
5
+ __version__ = "0.1.3"
@@ -0,0 +1,24 @@
1
+ """CLI entrypoint for chatcdn."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import click
6
+ from chatstyle import add_tree_option
7
+
8
+ from chatcdn import __version__
9
+
10
+
11
+ @click.group(
12
+ name="chatcdn",
13
+ context_settings={"help_option_names": ["-h", "--help"]},
14
+ invoke_without_command=True,
15
+ no_args_is_help=True,
16
+ )
17
+ @click.version_option(__version__, prog_name="chatcdn")
18
+ @add_tree_option(renderer_options={"root_name": "chatcdn"})
19
+ def main() -> None:
20
+ """ChatCDN command-line interface."""
21
+
22
+
23
+ if __name__ == "__main__":
24
+ main()
@@ -0,0 +1,63 @@
1
+ import click
2
+ from click.testing import CliRunner
3
+
4
+ from chatcdn import __version__
5
+ from chatcdn.cli import main
6
+
7
+
8
+ def test_version_option_reports_package_version():
9
+ result = CliRunner().invoke(main, ["--version"])
10
+
11
+ assert result.exit_code == 0
12
+ assert f"chatcdn, version {__version__}" in result.output
13
+
14
+
15
+ def test_help_mentions_tree_option():
16
+ result = CliRunner().invoke(main, ["--help"])
17
+
18
+ assert result.exit_code == 0, result.output
19
+ assert "--tree" in result.output
20
+ assert "--tree-brief" in result.output
21
+ assert "Print the registered CLI tree" in result.output
22
+
23
+
24
+ def test_tree_shows_registered_top_level_surface_with_purposes():
25
+ result = CliRunner().invoke(main, ["--tree"])
26
+
27
+ assert result.exit_code == 0, result.output
28
+ assert result.output.splitlines() == [
29
+ "chatcdn",
30
+ "├── --help # Show this message and exit.",
31
+ "├── --version # Show the version and exit.",
32
+ "├── --tree # Print the registered CLI tree and exit.",
33
+ "└── --tree-brief # Print the registered CLI tree without parameter signatures and exit.",
34
+ ]
35
+
36
+
37
+ def test_tree_defaults_to_signatures_and_brief_omits_them():
38
+ @click.command("probe")
39
+ @click.argument("source")
40
+ @click.option("--target")
41
+ def probe(source: str, target: str | None) -> None:
42
+ """Probe a parameterized command."""
43
+
44
+ main.add_command(probe)
45
+ try:
46
+ detailed = CliRunner().invoke(main, ["--tree"])
47
+ brief = CliRunner().invoke(main, ["--tree-brief"])
48
+ finally:
49
+ main.commands.pop("probe")
50
+
51
+ assert detailed.exit_code == 0, detailed.output
52
+ assert brief.exit_code == 0, brief.output
53
+ assert "└── probe <SOURCE> [--target TARGET] # Probe a parameterized command." in detailed.output
54
+ assert "└── probe # Probe a parameterized command." in brief.output
55
+ assert "<SOURCE>" not in brief.output
56
+ assert "[--target TARGET]" not in brief.output
57
+
58
+
59
+ def test_template_hello_command_is_not_registered():
60
+ result = CliRunner().invoke(main, ["hello"])
61
+
62
+ assert result.exit_code != 0
63
+ assert "No such command" in result.output
@@ -12,6 +12,8 @@ def test_mkdocs_material_i18n_public_domain_and_icon_renderer():
12
12
  assert "docs_structure: suffix" in mkdocs
13
13
  assert "mkdocs-static-i18n" in pyproject
14
14
  assert "mkdocs-material>=9.5,<10.0" in pyproject
15
+ assert "chatstyle>=0.2.0,<0.3.0" in pyproject
16
+ assert "chatenv>=0.2.10,<0.3.0" in pyproject
15
17
  assert "pymdownx.emoji" in mkdocs
16
18
  assert "material.extensions.emoji.twemoji" in mkdocs
17
19
  assert "material.extensions.emoji.to_svg" in mkdocs
@@ -23,5 +25,7 @@ def test_cli_tree_docs_are_bilingual_and_use_public_command():
23
25
 
24
26
  assert "chatcdn --tree" in zh
25
27
  assert "chatcdn --tree" in en
28
+ assert "chatcdn --tree-brief" in zh
29
+ assert "chatcdn --tree-brief" in en
26
30
  assert "python -m chatcdn.cli" not in zh
27
31
  assert "python -m chatcdn.cli" not in en
@@ -2,4 +2,4 @@ from chatcdn import __version__
2
2
 
3
3
 
4
4
  def test_version_present():
5
- assert __version__ == "0.1.2"
5
+ assert __version__ == "0.1.3"
@@ -19,6 +19,7 @@ def test_ci_smokes_installed_cli_and_checks_distributions():
19
19
 
20
20
  assert "chatcdn --version" in workflow
21
21
  assert "chatcdn --tree" in workflow
22
+ assert "chatcdn --tree-brief" in workflow
22
23
  assert "python -m twine check dist/*" in workflow
23
24
 
24
25
 
@@ -1,119 +0,0 @@
1
- """CLI entrypoint for chatcdn."""
2
-
3
- from __future__ import annotations
4
-
5
- from collections.abc import Iterable
6
-
7
- import click
8
-
9
- from chatcdn import __version__
10
-
11
-
12
- def _purpose(command: click.Command) -> str:
13
- """Return a compact one-line purpose for a Click command."""
14
- help_text = command.help or command.short_help or ""
15
- line = " ".join(help_text.strip().split())
16
- if not line:
17
- return "No description."
18
- return line if line.endswith(".") else f"{line}."
19
-
20
-
21
- def _format_param(param: click.Parameter) -> str | None:
22
- """Render a compact command-tree signature fragment for one parameter."""
23
- if isinstance(param, click.Option):
24
- if param.hidden:
25
- return None
26
- names = [name for name in param.opts if name.startswith("--")]
27
- if not names:
28
- names = list(param.opts)
29
- if not names:
30
- return None
31
- name = names[0]
32
- if param.is_bool_flag:
33
- return f"[{name}]"
34
- metavar = param.metavar or param.name.upper().replace("_", "-")
35
- return f"[{name} <{metavar}>]"
36
- if isinstance(param, click.Argument):
37
- metavar = param.metavar or param.name.upper().replace("_", "-")
38
- token = f"<{metavar}>"
39
- if not param.required:
40
- return f"[{token}]"
41
- return token
42
- return None
43
-
44
-
45
- def _signature(command: click.Command) -> str:
46
- parts = [part for part in (_format_param(param) for param in command.params) if part]
47
- return " ".join(parts)
48
-
49
-
50
- def _iter_visible_commands(command: click.Command) -> Iterable[tuple[str, click.Command]]:
51
- if not isinstance(command, click.Group):
52
- return []
53
- ctx = click.Context(command)
54
- commands: list[tuple[str, click.Command]] = []
55
- for name in command.list_commands(ctx):
56
- child = command.get_command(ctx, name)
57
- if child is not None and not child.hidden:
58
- commands.append((name, child))
59
- return commands
60
-
61
-
62
- def render_cli_tree(command: click.Command, *, root_name: str = "chatcdn") -> str:
63
- """Render the registered Click command tree with compact purpose comments."""
64
- lines = [f"{root_name} # {_purpose(command)}"]
65
- pseudo_leaves = [
66
- ("--help", "Show this help message."),
67
- ("--version", "Show the installed package version."),
68
- ("--tree", "Print the registered command tree."),
69
- ]
70
- children = list(_iter_visible_commands(command))
71
- entries: list[tuple[str, str, click.Command | None]] = []
72
- entries.extend((name, purpose, None) for name, purpose in pseudo_leaves)
73
- entries.extend((name, _purpose(child), child) for name, child in children)
74
-
75
- def visit(entries: list[tuple[str, str, click.Command | None]], prefix: str = "") -> None:
76
- for index, (name, purpose, child) in enumerate(entries):
77
- is_last = index == len(entries) - 1
78
- branch = "└──" if is_last else "├──"
79
- if child is None:
80
- lines.append(f"{prefix}{branch} {name} # {purpose}")
81
- continue
82
- signature = _signature(child)
83
- label = f"{name} {signature}" if signature else name
84
- lines.append(f"{prefix}{branch} {label} # {purpose}")
85
- grand_children: list[tuple[str, str, click.Command | None]] = [
86
- (child_name, _purpose(grand_child), grand_child)
87
- for child_name, grand_child in _iter_visible_commands(child)
88
- ]
89
- if grand_children:
90
- child_prefix = prefix + (" " if is_last else "│ ")
91
- visit(grand_children, child_prefix)
92
-
93
- visit(entries)
94
- return "\n".join(lines)
95
-
96
-
97
- @click.group(
98
- context_settings={"help_option_names": ["-h", "--help"]},
99
- invoke_without_command=True,
100
- no_args_is_help=True,
101
- )
102
- @click.version_option(__version__, prog_name="chatcdn")
103
- @click.option(
104
- "--tree",
105
- is_flag=True,
106
- is_eager=True,
107
- expose_value=True,
108
- help="Print the registered command tree and exit.",
109
- )
110
- @click.pass_context
111
- def main(ctx: click.Context, tree: bool) -> None:
112
- """ChatCDN command-line interface."""
113
- if tree:
114
- click.echo(render_cli_tree(ctx.command, root_name="chatcdn"))
115
- ctx.exit()
116
-
117
-
118
- if __name__ == "__main__":
119
- main()
@@ -1,37 +0,0 @@
1
- from click.testing import CliRunner
2
-
3
- from chatcdn import __version__
4
- from chatcdn.cli import main
5
-
6
-
7
- def test_version_option_reports_package_version():
8
- result = CliRunner().invoke(main, ["--version"])
9
-
10
- assert result.exit_code == 0
11
- assert f"chatcdn, version {__version__}" in result.output
12
-
13
-
14
- def test_help_mentions_tree_option():
15
- result = CliRunner().invoke(main, ["--help"])
16
-
17
- assert result.exit_code == 0, result.output
18
- assert "--tree" in result.output
19
- assert "Print the registered command tree" in result.output
20
-
21
-
22
- def test_tree_shows_registered_top_level_surface_with_purposes():
23
- result = CliRunner().invoke(main, ["--tree"])
24
-
25
- assert result.exit_code == 0, result.output
26
- assert "chatcdn # ChatCDN command-line interface." in result.output
27
- assert "├── --help # Show this help message." in result.output
28
- assert "├── --version # Show the installed package version." in result.output
29
- assert "└── --tree # Print the registered command tree." in result.output
30
- assert "#" in result.output
31
-
32
-
33
- def test_template_hello_command_is_not_registered():
34
- result = CliRunner().invoke(main, ["hello"])
35
-
36
- assert result.exit_code != 0
37
- assert "No such command" in result.output
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes