From 6a004a54b9bbff6cde65ea56ab8e87e5fcb1d761 Mon Sep 17 00:00:00 2001 From: gooker_young Date: Sun, 21 Jun 2026 21:11:07 +0800 Subject: [PATCH] ~ --- pyproject.toml | 1 + src/pyflowx/cli/gittool.py | 48 ++++++++++++++++++++++++++++++++++++++ uv.lock | 2 +- 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/pyflowx/cli/gittool.py diff --git a/pyproject.toml b/pyproject.toml index dc755d0..9718c8f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,6 +21,7 @@ version = "0.1.6" [project.scripts] pymake = "pyflowx.cli.pymake:main" +gitt = "pyflowx.cli.gittool:main" [project.optional-dependencies] dev = [ diff --git a/src/pyflowx/cli/gittool.py b/src/pyflowx/cli/gittool.py new file mode 100644 index 0000000..ab59d4b --- /dev/null +++ b/src/pyflowx/cli/gittool.py @@ -0,0 +1,48 @@ +"""Git 工具模块. + +提供 Git 仓库管理的常用操作封装, +支持初始化、提交、清理、推送等功能. +""" + +from __future__ import annotations + +import os +from pathlib import Path + +import pyflowx as px + + +def init_sub_dirs() -> None: + """初始化子目录的Git仓库.""" + origin = Path.cwd() + sub_dirs = [subdir for subdir in Path.cwd().iterdir() if subdir.is_dir()] + for subdir in sub_dirs: + os.chdir(str(subdir)) + _ = px.run( + [ + ["git", "init"], + ["git", "add", "."], + ["git", "commit", "-m", "init commit"], + ], + ) + os.chdir(str(origin)) + + +push: px.TaskSpec = px.TaskSpec("push", cmd=["git", "push"]) +pull: px.TaskSpec = px.TaskSpec("pull", cmd=["git", "pull"]) +kill_tgit: px.TaskSpec = px.TaskSpec("task_kill", cmd=["taskkill", "/f", "/t", "/im", "tgitcache.exe"]) + + +def main() -> None: + """Git工具主函数.""" + runner = px.CliRunner( + strategy="thread", + description="Gittool - Git 执行工具.", + graphs={ + "isub": px.Graph.from_specs([px.TaskSpec("isub", fn=init_sub_dirs)]), + "p": px.Graph.from_specs([push]), + "pl": px.Graph.from_specs([pull]), + "r": px.Graph.from_specs([kill_tgit]), + }, + ) + runner.run_cli() diff --git a/uv.lock b/uv.lock index 9caf3a9..0d6a53b 100644 --- a/uv.lock +++ b/uv.lock @@ -1875,7 +1875,7 @@ wheels = [ [[package]] name = "pyflowx" -version = "0.1.5" +version = "0.1.6" source = { editable = "." } dependencies = [ { name = "graphlib-backport", marker = "python_full_version < '3.9'" },