From 7d4e8a40ce2b0c184cf445d832f30e81c4f75b58 Mon Sep 17 00:00:00 2001 From: gooker_young Date: Sat, 27 Jun 2026 22:01:02 +0800 Subject: [PATCH] =?UTF-8?q?refactor(cli):=20=E9=87=8D=E6=9E=84CLI=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=93=E6=9E=84=EF=BC=8C=E6=95=B4=E7=90=86=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E5=B7=A5=E5=85=B7=E4=B8=8E=E5=BC=80=E5=8F=91=E5=B7=A5?= =?UTF-8?q?=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 将原cli根目录下的clearscreen、taskkill、which工具迁移到cli/system子目录 2. 新增cli/dev子目录并添加envdev环境配置工具 3. 更新pyproject.toml中的脚本入口点映射 4. 调整tests/cli下的测试文件导入路径 5. 整理tasks/system.py的__all__导出顺序 --- pyproject.toml | 10 ++++++---- src/pyflowx/cli/dev/__init__.py | 0 src/pyflowx/cli/{ => dev}/envdev.py | 0 src/pyflowx/cli/system/__init__.py | 0 src/pyflowx/cli/{ => system}/clearscreen.py | 0 src/pyflowx/cli/{ => system}/taskkill.py | 2 +- src/pyflowx/cli/{ => system}/which.py | 0 src/pyflowx/tasks/system.py | 12 +++++++++--- tests/cli/test_clearscreen.py | 2 +- tests/cli/test_taskkill.py | 2 +- 10 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 src/pyflowx/cli/dev/__init__.py rename src/pyflowx/cli/{ => dev}/envdev.py (100%) create mode 100644 src/pyflowx/cli/system/__init__.py rename src/pyflowx/cli/{ => system}/clearscreen.py (100%) rename src/pyflowx/cli/{ => system}/taskkill.py (98%) rename src/pyflowx/cli/{ => system}/which.py (100%) diff --git a/pyproject.toml b/pyproject.toml index d0a4f21..c97c5d8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,9 +26,7 @@ version = "0.2.10" [project.scripts] autofmt = "pyflowx.cli.autofmt:main" bumpversion = "pyflowx.cli.bumpversion:main" -clr = "pyflowx.cli.clearscreen:main" emlman = "pyflowx.cli.emlmanager:main" -envdev = "pyflowx.cli.envdev:main" filedate = "pyflowx.cli.filedate:main" filelvl = "pyflowx.cli.filelevel:main" foldback = "pyflowx.cli.folderback:main" @@ -44,8 +42,12 @@ reseticon = "pyflowx.cli.reseticoncache:main" scrcap = "pyflowx.cli.screenshot:main" sglang = "pyflowx.cli.llm.sglang:main" sshcopy = "pyflowx.cli.sshcopyid:main" -taskk = "pyflowx.cli.taskkill:main" -wch = "pyflowx.cli.which:main" +# dev +envdev = "pyflowx.cli.dev.envdev:main" +# system +clr = "pyflowx.cli.system.clearscreen:main" +taskk = "pyflowx.cli.system.taskkill:main" +wch = "pyflowx.cli.system.which:main" [project.optional-dependencies] dev = [ diff --git a/src/pyflowx/cli/dev/__init__.py b/src/pyflowx/cli/dev/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/pyflowx/cli/envdev.py b/src/pyflowx/cli/dev/envdev.py similarity index 100% rename from src/pyflowx/cli/envdev.py rename to src/pyflowx/cli/dev/envdev.py diff --git a/src/pyflowx/cli/system/__init__.py b/src/pyflowx/cli/system/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/pyflowx/cli/clearscreen.py b/src/pyflowx/cli/system/clearscreen.py similarity index 100% rename from src/pyflowx/cli/clearscreen.py rename to src/pyflowx/cli/system/clearscreen.py diff --git a/src/pyflowx/cli/taskkill.py b/src/pyflowx/cli/system/taskkill.py similarity index 98% rename from src/pyflowx/cli/taskkill.py rename to src/pyflowx/cli/system/taskkill.py index a07148b..3cb261c 100644 --- a/src/pyflowx/cli/taskkill.py +++ b/src/pyflowx/cli/system/taskkill.py @@ -35,6 +35,6 @@ def main() -> None: [ px.TaskSpec(f"kill_{proc_name}", cmd=[*cmd, f"{proc_name}*"], verbose=True) for proc_name in args.process_names - ] + ], ) px.run(graph, strategy="thread") diff --git a/src/pyflowx/cli/which.py b/src/pyflowx/cli/system/which.py similarity index 100% rename from src/pyflowx/cli/which.py rename to src/pyflowx/cli/system/which.py diff --git a/src/pyflowx/tasks/system.py b/src/pyflowx/tasks/system.py index 4ca1c6d..eb60dc4 100644 --- a/src/pyflowx/tasks/system.py +++ b/src/pyflowx/tasks/system.py @@ -6,6 +6,15 @@ from __future__ import annotations +__all__ = [ + "clr", + "reset_icon_cache", + "setenv", + "setenv_group", + "which", + "write_file", +] + import os import subprocess from pathlib import Path @@ -111,6 +120,3 @@ def write_file(path: str, content: str, encoding: str = "utf-8") -> px.TaskSpec: print(f"写入文件 {path} 失败: {e}") return px.TaskSpec(f"write_file_{path}", fn=write, verbose=True) - - -__all__ = ["clr", "reset_icon_cache", "setenv", "setenv_group", "which", "write_file"] diff --git a/tests/cli/test_clearscreen.py b/tests/cli/test_clearscreen.py index c2f8171..7ce53af 100644 --- a/tests/cli/test_clearscreen.py +++ b/tests/cli/test_clearscreen.py @@ -5,7 +5,7 @@ from __future__ import annotations from unittest.mock import patch import pyflowx as px -from pyflowx.cli import clearscreen +from pyflowx.cli.system import clearscreen # ---------------------------------------------------------------------- # diff --git a/tests/cli/test_taskkill.py b/tests/cli/test_taskkill.py index e137d42..f9e7d6c 100644 --- a/tests/cli/test_taskkill.py +++ b/tests/cli/test_taskkill.py @@ -7,7 +7,7 @@ from unittest.mock import patch import pytest import pyflowx as px -from pyflowx.cli import taskkill +from pyflowx.cli.system import taskkill from pyflowx.conditions import Constants