colyn-cli 3.1.4
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.
- package/README-en.md +85 -0
- package/README.md +85 -0
- package/bin/colyn +25 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +116 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/add.d.ts +6 -0
- package/dist/commands/add.d.ts.map +1 -0
- package/dist/commands/add.helpers.d.ts +48 -0
- package/dist/commands/add.helpers.d.ts.map +1 -0
- package/dist/commands/add.helpers.js +251 -0
- package/dist/commands/add.helpers.js.map +1 -0
- package/dist/commands/add.js +286 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/checkout.d.ts +16 -0
- package/dist/commands/checkout.d.ts.map +1 -0
- package/dist/commands/checkout.js +428 -0
- package/dist/commands/checkout.js.map +1 -0
- package/dist/commands/completion.d.ts +10 -0
- package/dist/commands/completion.d.ts.map +1 -0
- package/dist/commands/completion.js +380 -0
- package/dist/commands/completion.js.map +1 -0
- package/dist/commands/config.d.ts +11 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +338 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/index.d.ts +10 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +41 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/info.d.ts +6 -0
- package/dist/commands/info.d.ts.map +1 -0
- package/dist/commands/info.js +374 -0
- package/dist/commands/info.js.map +1 -0
- package/dist/commands/init.d.ts +6 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.handlers.d.ts +27 -0
- package/dist/commands/init.handlers.d.ts.map +1 -0
- package/dist/commands/init.handlers.js +314 -0
- package/dist/commands/init.handlers.js.map +1 -0
- package/dist/commands/init.helpers.d.ts +42 -0
- package/dist/commands/init.helpers.d.ts.map +1 -0
- package/dist/commands/init.helpers.js +275 -0
- package/dist/commands/init.helpers.js.map +1 -0
- package/dist/commands/init.js +61 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/install.d.ts +6 -0
- package/dist/commands/install.d.ts.map +1 -0
- package/dist/commands/install.helpers.d.ts +32 -0
- package/dist/commands/install.helpers.d.ts.map +1 -0
- package/dist/commands/install.helpers.js +124 -0
- package/dist/commands/install.helpers.js.map +1 -0
- package/dist/commands/install.js +104 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/list-project.d.ts +11 -0
- package/dist/commands/list-project.d.ts.map +1 -0
- package/dist/commands/list-project.js +260 -0
- package/dist/commands/list-project.js.map +1 -0
- package/dist/commands/list.d.ts +15 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.helpers.d.ts +50 -0
- package/dist/commands/list.helpers.d.ts.map +1 -0
- package/dist/commands/list.helpers.js +143 -0
- package/dist/commands/list.helpers.js.map +1 -0
- package/dist/commands/list.js +530 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/merge.d.ts +6 -0
- package/dist/commands/merge.d.ts.map +1 -0
- package/dist/commands/merge.helpers.d.ts +74 -0
- package/dist/commands/merge.helpers.d.ts.map +1 -0
- package/dist/commands/merge.helpers.js +307 -0
- package/dist/commands/merge.helpers.js.map +1 -0
- package/dist/commands/merge.js +260 -0
- package/dist/commands/merge.js.map +1 -0
- package/dist/commands/release.d.ts +6 -0
- package/dist/commands/release.d.ts.map +1 -0
- package/dist/commands/release.helpers.d.ts +61 -0
- package/dist/commands/release.helpers.d.ts.map +1 -0
- package/dist/commands/release.helpers.js +277 -0
- package/dist/commands/release.helpers.js.map +1 -0
- package/dist/commands/release.js +127 -0
- package/dist/commands/release.js.map +1 -0
- package/dist/commands/remove.d.ts +6 -0
- package/dist/commands/remove.d.ts.map +1 -0
- package/dist/commands/remove.helpers.d.ts +59 -0
- package/dist/commands/remove.helpers.d.ts.map +1 -0
- package/dist/commands/remove.helpers.js +190 -0
- package/dist/commands/remove.helpers.js.map +1 -0
- package/dist/commands/remove.js +137 -0
- package/dist/commands/remove.js.map +1 -0
- package/dist/commands/repair.d.ts +6 -0
- package/dist/commands/repair.d.ts.map +1 -0
- package/dist/commands/repair.helpers.d.ts +5 -0
- package/dist/commands/repair.helpers.d.ts.map +1 -0
- package/dist/commands/repair.helpers.js +499 -0
- package/dist/commands/repair.helpers.js.map +1 -0
- package/dist/commands/repair.js +28 -0
- package/dist/commands/repair.js.map +1 -0
- package/dist/commands/status.d.ts +6 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +116 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/system-integration.d.ts +6 -0
- package/dist/commands/system-integration.d.ts.map +1 -0
- package/dist/commands/system-integration.helpers.d.ts +70 -0
- package/dist/commands/system-integration.helpers.d.ts.map +1 -0
- package/dist/commands/system-integration.helpers.js +313 -0
- package/dist/commands/system-integration.helpers.js.map +1 -0
- package/dist/commands/system-integration.js +132 -0
- package/dist/commands/system-integration.js.map +1 -0
- package/dist/commands/tmux.d.ts +11 -0
- package/dist/commands/tmux.d.ts.map +1 -0
- package/dist/commands/tmux.js +500 -0
- package/dist/commands/tmux.js.map +1 -0
- package/dist/commands/todo.d.ts +6 -0
- package/dist/commands/todo.d.ts.map +1 -0
- package/dist/commands/todo.helpers.d.ts +50 -0
- package/dist/commands/todo.helpers.d.ts.map +1 -0
- package/dist/commands/todo.helpers.js +297 -0
- package/dist/commands/todo.helpers.js.map +1 -0
- package/dist/commands/todo.js +579 -0
- package/dist/commands/todo.js.map +1 -0
- package/dist/commands/update.d.ts +18 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.helpers.d.ts +89 -0
- package/dist/commands/update.helpers.d.ts.map +1 -0
- package/dist/commands/update.helpers.js +335 -0
- package/dist/commands/update.helpers.js.map +1 -0
- package/dist/commands/update.js +187 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/core/config-loader.d.ts +47 -0
- package/dist/core/config-loader.d.ts.map +1 -0
- package/dist/core/config-loader.js +188 -0
- package/dist/core/config-loader.js.map +1 -0
- package/dist/core/config-merger.d.ts +29 -0
- package/dist/core/config-merger.d.ts.map +1 -0
- package/dist/core/config-merger.js +100 -0
- package/dist/core/config-merger.js.map +1 -0
- package/dist/core/config-migration.d.ts +64 -0
- package/dist/core/config-migration.d.ts.map +1 -0
- package/dist/core/config-migration.js +340 -0
- package/dist/core/config-migration.js.map +1 -0
- package/dist/core/config-new.d.ts +19 -0
- package/dist/core/config-new.d.ts.map +1 -0
- package/dist/core/config-new.js +58 -0
- package/dist/core/config-new.js.map +1 -0
- package/dist/core/config-schema.d.ts +221 -0
- package/dist/core/config-schema.d.ts.map +1 -0
- package/dist/core/config-schema.js +168 -0
- package/dist/core/config-schema.js.map +1 -0
- package/dist/core/config.d.ts +55 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +143 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/dev-server.d.ts +29 -0
- package/dist/core/dev-server.d.ts.map +1 -0
- package/dist/core/dev-server.js +54 -0
- package/dist/core/dev-server.js.map +1 -0
- package/dist/core/discovery.d.ts +51 -0
- package/dist/core/discovery.d.ts.map +1 -0
- package/dist/core/discovery.js +247 -0
- package/dist/core/discovery.js.map +1 -0
- package/dist/core/env.d.ts +13 -0
- package/dist/core/env.d.ts.map +1 -0
- package/dist/core/env.js +75 -0
- package/dist/core/env.js.map +1 -0
- package/dist/core/git.d.ts +31 -0
- package/dist/core/git.d.ts.map +1 -0
- package/dist/core/git.js +56 -0
- package/dist/core/git.js.map +1 -0
- package/dist/core/paths.d.ts +86 -0
- package/dist/core/paths.d.ts.map +1 -0
- package/dist/core/paths.js +256 -0
- package/dist/core/paths.js.map +1 -0
- package/dist/core/tmux-config.d.ts +174 -0
- package/dist/core/tmux-config.d.ts.map +1 -0
- package/dist/core/tmux-config.js +545 -0
- package/dist/core/tmux-config.js.map +1 -0
- package/dist/core/tmux-config.legacy.d.ts +243 -0
- package/dist/core/tmux-config.legacy.d.ts.map +1 -0
- package/dist/core/tmux-config.legacy.js +896 -0
- package/dist/core/tmux-config.legacy.js.map +1 -0
- package/dist/core/tmux.d.ts +214 -0
- package/dist/core/tmux.d.ts.map +1 -0
- package/dist/core/tmux.js +712 -0
- package/dist/core/tmux.js.map +1 -0
- package/dist/core/toolchain-resolver.d.ts +51 -0
- package/dist/core/toolchain-resolver.d.ts.map +1 -0
- package/dist/core/toolchain-resolver.js +364 -0
- package/dist/core/toolchain-resolver.js.map +1 -0
- package/dist/core/worktree-status.d.ts +20 -0
- package/dist/core/worktree-status.d.ts.map +1 -0
- package/dist/core/worktree-status.js +67 -0
- package/dist/core/worktree-status.js.map +1 -0
- package/dist/i18n/index.d.ts +36 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +157 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/locales/en.d.ts +866 -0
- package/dist/i18n/locales/en.d.ts.map +1 -0
- package/dist/i18n/locales/en.js +985 -0
- package/dist/i18n/locales/en.js.map +1 -0
- package/dist/i18n/locales/zh-CN.d.ts +865 -0
- package/dist/i18n/locales/zh-CN.d.ts.map +1 -0
- package/dist/i18n/locales/zh-CN.js +985 -0
- package/dist/i18n/locales/zh-CN.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/builtin/gradle.d.ts +9 -0
- package/dist/plugins/builtin/gradle.d.ts.map +1 -0
- package/dist/plugins/builtin/gradle.js +164 -0
- package/dist/plugins/builtin/gradle.js.map +1 -0
- package/dist/plugins/builtin/maven.d.ts +9 -0
- package/dist/plugins/builtin/maven.d.ts.map +1 -0
- package/dist/plugins/builtin/maven.js +127 -0
- package/dist/plugins/builtin/maven.js.map +1 -0
- package/dist/plugins/builtin/npm.d.ts +9 -0
- package/dist/plugins/builtin/npm.d.ts.map +1 -0
- package/dist/plugins/builtin/npm.js +238 -0
- package/dist/plugins/builtin/npm.js.map +1 -0
- package/dist/plugins/builtin/pip.d.ts +9 -0
- package/dist/plugins/builtin/pip.d.ts.map +1 -0
- package/dist/plugins/builtin/pip.js +210 -0
- package/dist/plugins/builtin/pip.js.map +1 -0
- package/dist/plugins/builtin/xcode.d.ts +12 -0
- package/dist/plugins/builtin/xcode.d.ts.map +1 -0
- package/dist/plugins/builtin/xcode.js +438 -0
- package/dist/plugins/builtin/xcode.js.map +1 -0
- package/dist/plugins/index.d.ts +13 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +24 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/manager.d.ts +93 -0
- package/dist/plugins/manager.d.ts.map +1 -0
- package/dist/plugins/manager.js +270 -0
- package/dist/plugins/manager.js.map +1 -0
- package/dist/plugins/utils.d.ts +42 -0
- package/dist/plugins/utils.d.ts.map +1 -0
- package/dist/plugins/utils.js +175 -0
- package/dist/plugins/utils.js.map +1 -0
- package/dist/types/index.d.ts +104 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +21 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/plugin.d.ts +200 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/dist/types/plugin.js +19 -0
- package/dist/types/plugin.js.map +1 -0
- package/dist/utils/logger.d.ts +42 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +80 -0
- package/dist/utils/logger.js.map +1 -0
- package/docs/en/manual/04-command-reference/README.md +58 -0
- package/docs/en/manual/README.md +108 -0
- package/docs/zh-CN/manual/04-command-reference/README.md +58 -0
- package/docs/zh-CN/manual/README.md +108 -0
- package/package.json +65 -0
- package/shell/colyn.sh +55 -0
- package/shell/completion.bash +270 -0
- package/shell/completion.zsh +167 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Colyn 用户手册
|
|
2
|
+
|
|
3
|
+
**版本**: 2.5.5
|
|
4
|
+
**最后更新**: 2026-02-10
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 欢迎使用 Colyn
|
|
9
|
+
|
|
10
|
+
Colyn 是一个强大的 Git Worktree 管理工具,专为需要并行开发多个功能的开发者设计。它简化了 Git worktree 的创建和管理流程,自动处理端口分配,支持 tmux 集成,让你能够轻松实现多分支并行开发。
|
|
11
|
+
|
|
12
|
+
### 核心特性
|
|
13
|
+
|
|
14
|
+
- **🚀 简化 Worktree 管理**: 一键创建和管理 git worktree,无需复杂的命令
|
|
15
|
+
- **🎯 自动端口分配**: 智能分配开发服务器端口,避免端口冲突
|
|
16
|
+
- **📁 自动目录切换**: 命令执行后自动切换到目标目录
|
|
17
|
+
- **🔍 智能分支处理**: 自动识别本地分支、远程分支或创建新分支
|
|
18
|
+
- **⚡ 自动补全**: 支持 Bash/Zsh Tab 键补全命令、选项和参数
|
|
19
|
+
- **🖥️ tmux 集成**: 在 tmux 中实现高效的 worktree 管理和切换
|
|
20
|
+
- **🌐 跨平台支持**: macOS、Linux、Windows 全平台支持
|
|
21
|
+
|
|
22
|
+
### 适用场景
|
|
23
|
+
|
|
24
|
+
Colyn 特别适合以下使用场景:
|
|
25
|
+
|
|
26
|
+
- **并行功能开发**: 同时开发多个功能,无需频繁切换分支
|
|
27
|
+
- **多版本测试**: 在不同分支上同时运行开发服务器进行对比测试
|
|
28
|
+
- **Bug 修复**: 保持当前开发状态,快速切换到 bugfix 分支
|
|
29
|
+
- **代码审查**: 在独立环境中审查他人的分支代码
|
|
30
|
+
- **AI 协作开发**: 使用 Claude Code 等 AI 工具实现"并行 Vibe Coding"
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 手册结构
|
|
35
|
+
|
|
36
|
+
本用户手册包含以下章节:
|
|
37
|
+
|
|
38
|
+
0. **[用户故事:从一个人到一支 AI 团队](00-user-story.md)** - 通过一个完整的真实场景,了解 Colyn 能做什么
|
|
39
|
+
1. **[快速开始](01-quick-start.md)** - 5 分钟快速上手
|
|
40
|
+
2. **[安装指南](02-installation.md)** - 详细的安装说明
|
|
41
|
+
3. **[核心概念](03-core-concepts.md)** - 理解 Colyn 的工作原理
|
|
42
|
+
4. **[命令参考](04-command-reference/README.md)** - 所有命令的详细说明(按分类组织)
|
|
43
|
+
5. **[高级用法](05-advanced-usage.md)** - 高级功能和技巧
|
|
44
|
+
6. **[tmux 集成](06-tmux-integration.md)** - tmux 环境下的高效工作流
|
|
45
|
+
7. **[最佳实践](07-best-practices.md)** - 推荐的工作流程和技巧
|
|
46
|
+
8. **[故障排除](08-troubleshooting.md)** - 常见问题和解决方案
|
|
47
|
+
9. **[术语表](09-glossary.md)** - 术语和概念速查
|
|
48
|
+
10. **[配置系统](10-configuration.md)** - 完整的配置文件指南
|
|
49
|
+
11. **[插件系统](11-plugin-system.md)** - 多语言工具链支持(npm / Maven / Gradle / pip)
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## 快速导航
|
|
54
|
+
|
|
55
|
+
### 新用户
|
|
56
|
+
|
|
57
|
+
如果你是第一次使用 Colyn:
|
|
58
|
+
|
|
59
|
+
1. 阅读 [用户故事](00-user-story.md) 快速了解 Colyn 能解决什么问题
|
|
60
|
+
2. 阅读 [快速开始](01-quick-start.md) 了解基本用法
|
|
61
|
+
3. 查看 [核心概念](03-core-concepts.md) 理解工作原理
|
|
62
|
+
4. 参考 [命令参考](04-command-reference/README.md) 学习具体命令
|
|
63
|
+
|
|
64
|
+
### 已有用户
|
|
65
|
+
|
|
66
|
+
如果你已经在使用 Colyn:
|
|
67
|
+
|
|
68
|
+
- 需要特定命令说明 → [命令参考](04-command-reference/README.md)
|
|
69
|
+
- 配置文件设置 → [配置系统](10-configuration.md)
|
|
70
|
+
- 遇到问题 → [故障排除](08-troubleshooting.md)
|
|
71
|
+
- 查找术语 → [术语表](09-glossary.md)
|
|
72
|
+
- 学习高级技巧 → [高级用法](05-advanced-usage.md)
|
|
73
|
+
|
|
74
|
+
### tmux 用户
|
|
75
|
+
|
|
76
|
+
如果你使用 tmux:
|
|
77
|
+
|
|
78
|
+
- 完整的 tmux 集成指南 → [tmux 集成](06-tmux-integration.md)
|
|
79
|
+
- 快捷键和工作流 → [最佳实践](07-best-practices.md)
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## 获取帮助
|
|
84
|
+
|
|
85
|
+
### 命令行帮助
|
|
86
|
+
|
|
87
|
+
在命令行中随时查看帮助:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# 查看所有命令
|
|
91
|
+
colyn --help
|
|
92
|
+
|
|
93
|
+
# 查看特定命令的帮助
|
|
94
|
+
colyn init --help
|
|
95
|
+
colyn add --help
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 项目信息
|
|
99
|
+
|
|
100
|
+
- **GitHub 仓库**: [github.com/colinhan/colyn](https://github.com/colinhan/colyn)
|
|
101
|
+
- **问题反馈**: [GitHub Issues](https://github.com/colinhan/colyn/issues)
|
|
102
|
+
- **版本历史**: [CHANGELOG.md](../CHANGELOG.md)
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## 开始使用
|
|
107
|
+
|
|
108
|
+
准备好了吗?从 [快速开始](01-quick-start.md) 开始你的 Colyn 之旅!
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "colyn-cli",
|
|
3
|
+
"version": "3.1.4",
|
|
4
|
+
"description": "Git worktree 管理工具",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": "./bin/colyn",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/",
|
|
9
|
+
"bin/",
|
|
10
|
+
"shell/",
|
|
11
|
+
"README.md",
|
|
12
|
+
"README-en.md"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"dev": "tsc --watch",
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"prepack": "yarn build",
|
|
18
|
+
"colyn": "node dist/index.js",
|
|
19
|
+
"install-to": "node scripts/install.js",
|
|
20
|
+
"test": "vitest",
|
|
21
|
+
"test:ui": "vitest --ui",
|
|
22
|
+
"test:coverage": "vitest --coverage",
|
|
23
|
+
"lint": "eslint src --ext .ts",
|
|
24
|
+
"format": "prettier --write \"src/**/*.ts\""
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"git",
|
|
28
|
+
"worktree",
|
|
29
|
+
"cli",
|
|
30
|
+
"development"
|
|
31
|
+
],
|
|
32
|
+
"author": "",
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"chalk": "^5.3.0",
|
|
36
|
+
"chokidar": "^5.0.0",
|
|
37
|
+
"cli-table3": "^0.6.3",
|
|
38
|
+
"commander": "^12.0.0",
|
|
39
|
+
"deepmerge": "^4.3.1",
|
|
40
|
+
"dotenv": "^16.4.0",
|
|
41
|
+
"enquirer": "^2.4.1",
|
|
42
|
+
"i18next": "^25.8.0",
|
|
43
|
+
"js-yaml": "^4.1.1",
|
|
44
|
+
"json5": "^2.2.3",
|
|
45
|
+
"ora": "^8.0.1",
|
|
46
|
+
"simple-git": "^3.22.0",
|
|
47
|
+
"zod": "^4.3.6"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/chokidar": "^2.1.7",
|
|
51
|
+
"@types/deepmerge": "^2.2.3",
|
|
52
|
+
"@types/js-yaml": "^4",
|
|
53
|
+
"@types/node": "^20.11.0",
|
|
54
|
+
"@typescript-eslint/eslint-plugin": "^6.19.0",
|
|
55
|
+
"@typescript-eslint/parser": "^6.19.0",
|
|
56
|
+
"@vitest/ui": "^1.2.0",
|
|
57
|
+
"eslint": "^8.56.0",
|
|
58
|
+
"prettier": "^3.2.4",
|
|
59
|
+
"typescript": "^5.3.3",
|
|
60
|
+
"vitest": "^1.2.0"
|
|
61
|
+
},
|
|
62
|
+
"engines": {
|
|
63
|
+
"node": ">=18.0.0"
|
|
64
|
+
}
|
|
65
|
+
}
|
package/shell/colyn.sh
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Colyn Shell 集成(支持目录切换)
|
|
2
|
+
# 使用方法:将以下内容添加到 ~/.bashrc 或 ~/.zshrc
|
|
3
|
+
# source /path/to/colyn/shell/colyn.sh
|
|
4
|
+
|
|
5
|
+
colyn() {
|
|
6
|
+
# 定位 colyn 安装目录(兼容 bash 和 zsh)
|
|
7
|
+
local COLYN_SHELL_DIR
|
|
8
|
+
if [[ -n "${BASH_SOURCE[0]:-}" ]]; then
|
|
9
|
+
# bash
|
|
10
|
+
COLYN_SHELL_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
11
|
+
elif [[ -n "${ZSH_VERSION:-}" ]]; then
|
|
12
|
+
# zsh
|
|
13
|
+
COLYN_SHELL_DIR="$(cd "$(dirname "${(%):-%x}")" && pwd)"
|
|
14
|
+
else
|
|
15
|
+
# fallback
|
|
16
|
+
COLYN_SHELL_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
17
|
+
fi
|
|
18
|
+
|
|
19
|
+
local COLYN_BIN="${COLYN_SHELL_DIR}/../../colyn"
|
|
20
|
+
|
|
21
|
+
if [[ ! -f "$COLYN_BIN" ]]; then
|
|
22
|
+
echo "错误: 找不到 colyn" >&2
|
|
23
|
+
return 1
|
|
24
|
+
fi
|
|
25
|
+
|
|
26
|
+
# 调用 bin/colyn,捕获 stdout(JSON),stderr 直接显示
|
|
27
|
+
local result
|
|
28
|
+
result=$(COLYN_OUTPUT_JSON=1 "$COLYN_BIN" "$@")
|
|
29
|
+
local exit_code=$?
|
|
30
|
+
|
|
31
|
+
# 处理输出
|
|
32
|
+
if [[ -n "$result" ]]; then
|
|
33
|
+
# 尝试解析 JSON
|
|
34
|
+
local target_dir display_path attach_session is_json_result
|
|
35
|
+
target_dir=$(node -e "try{const r=JSON.parse(process.argv[1]);if(r.success&&r.targetDir)console.log(r.targetDir)}catch(e){process.exit(1)}" "$result" 2>/dev/null)
|
|
36
|
+
attach_session=$(node -e "try{const r=JSON.parse(process.argv[1]);if(r.success&&r.attachSession)console.log(r.attachSession)}catch(e){}" "$result" 2>/dev/null)
|
|
37
|
+
node -e "try{JSON.parse(process.argv[1]);process.exit(0)}catch(e){process.exit(1)}" "$result" 2>/dev/null
|
|
38
|
+
is_json_result=$?
|
|
39
|
+
|
|
40
|
+
if [[ $? -eq 0 && -n "$attach_session" ]]; then
|
|
41
|
+
# 需要连接到 tmux session
|
|
42
|
+
exec tmux attach-session -t "$attach_session"
|
|
43
|
+
elif [[ $? -eq 0 && -n "$target_dir" && -d "$target_dir" ]]; then
|
|
44
|
+
# 是 JSON 且有目标目录
|
|
45
|
+
display_path=$(node -e "try{const r=JSON.parse(process.argv[1]);console.log(r.displayPath||r.targetDir)}catch(e){}" "$result" 2>/dev/null)
|
|
46
|
+
cd "$target_dir" || return
|
|
47
|
+
echo "📂 已切换到: $display_path"
|
|
48
|
+
elif [[ $is_json_result -ne 0 ]]; then
|
|
49
|
+
# 不是 JSON,原样输出(如 --help)
|
|
50
|
+
echo "$result"
|
|
51
|
+
fi
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
return $exit_code
|
|
55
|
+
}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Bash completion script for colyn
|
|
3
|
+
#
|
|
4
|
+
# Installation:
|
|
5
|
+
# source /path/to/completion.bash
|
|
6
|
+
# Or add to ~/.bashrc:
|
|
7
|
+
# echo "source /path/to/completion.bash" >> ~/.bashrc
|
|
8
|
+
|
|
9
|
+
_colyn_completion() {
|
|
10
|
+
local cur prev words cword
|
|
11
|
+
_init_completion || return
|
|
12
|
+
|
|
13
|
+
# 所有可用命令
|
|
14
|
+
local commands="init add list list-project lsp merge update remove checkout info status repair config setup tmux release completion todo"
|
|
15
|
+
|
|
16
|
+
# 当前命令(第一个参数)
|
|
17
|
+
local command="${words[1]}"
|
|
18
|
+
|
|
19
|
+
# 如果还没有输入命令,补全命令列表
|
|
20
|
+
if [[ $cword -eq 1 ]]; then
|
|
21
|
+
COMPREPLY=($(compgen -W "$commands" -- "$cur"))
|
|
22
|
+
return 0
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
# 根据不同命令提供补全
|
|
26
|
+
case "$command" in
|
|
27
|
+
init)
|
|
28
|
+
# init 命令没有参数
|
|
29
|
+
return 0
|
|
30
|
+
;;
|
|
31
|
+
|
|
32
|
+
add)
|
|
33
|
+
# add <branch> - 补全 git 分支名
|
|
34
|
+
if [[ $cword -eq 2 ]]; then
|
|
35
|
+
# 获取所有本地和远程分支
|
|
36
|
+
local branches=$(git branch -a 2>/dev/null | sed 's/^[* ]*//' | sed 's/remotes\/origin\///' | sort -u)
|
|
37
|
+
COMPREPLY=($(compgen -W "$branches" -- "$cur"))
|
|
38
|
+
fi
|
|
39
|
+
return 0
|
|
40
|
+
;;
|
|
41
|
+
|
|
42
|
+
list)
|
|
43
|
+
# list 命令选项
|
|
44
|
+
local list_opts="--json --paths --no-main"
|
|
45
|
+
if [[ $cur == -* ]]; then
|
|
46
|
+
COMPREPLY=($(compgen -W "$list_opts" -- "$cur"))
|
|
47
|
+
fi
|
|
48
|
+
return 0
|
|
49
|
+
;;
|
|
50
|
+
|
|
51
|
+
merge)
|
|
52
|
+
# merge [id|branch] [--push|--no-push]
|
|
53
|
+
if [[ $cur == -* ]]; then
|
|
54
|
+
local merge_opts="--push --no-push"
|
|
55
|
+
COMPREPLY=($(compgen -W "$merge_opts" -- "$cur"))
|
|
56
|
+
elif [[ $cword -eq 2 ]]; then
|
|
57
|
+
# 补全 worktree ID 和分支名
|
|
58
|
+
_colyn_complete_worktrees
|
|
59
|
+
fi
|
|
60
|
+
return 0
|
|
61
|
+
;;
|
|
62
|
+
|
|
63
|
+
update)
|
|
64
|
+
# update [target] [--all] [--no-rebase]
|
|
65
|
+
if [[ $cur == -* ]]; then
|
|
66
|
+
local update_opts="--all --no-rebase"
|
|
67
|
+
COMPREPLY=($(compgen -W "$update_opts" -- "$cur"))
|
|
68
|
+
elif [[ $cword -eq 2 ]]; then
|
|
69
|
+
_colyn_complete_worktrees
|
|
70
|
+
fi
|
|
71
|
+
return 0
|
|
72
|
+
;;
|
|
73
|
+
|
|
74
|
+
remove)
|
|
75
|
+
# remove [id|branch] [-y|--yes] [-f|--force] [-d|--delete-branch]
|
|
76
|
+
if [[ $cur == -* ]]; then
|
|
77
|
+
local remove_opts="-y --yes -f --force -d --delete-branch"
|
|
78
|
+
COMPREPLY=($(compgen -W "$remove_opts" -- "$cur"))
|
|
79
|
+
elif [[ $cword -eq 2 ]]; then
|
|
80
|
+
# 补全 worktree ID 和分支名
|
|
81
|
+
_colyn_complete_worktrees
|
|
82
|
+
fi
|
|
83
|
+
return 0
|
|
84
|
+
;;
|
|
85
|
+
|
|
86
|
+
checkout|co)
|
|
87
|
+
# checkout [id] <branch>
|
|
88
|
+
if [[ $cword -eq 2 ]]; then
|
|
89
|
+
# 第一个参数可以是 worktree ID
|
|
90
|
+
_colyn_complete_worktree_ids
|
|
91
|
+
elif [[ $cword -eq 3 ]]; then
|
|
92
|
+
# 第二个参数是分支名
|
|
93
|
+
local branches=$(git branch -a 2>/dev/null | sed 's/^[* ]*//' | sed 's/remotes\/origin\///' | sort -u)
|
|
94
|
+
COMPREPLY=($(compgen -W "$branches" -- "$cur"))
|
|
95
|
+
fi
|
|
96
|
+
return 0
|
|
97
|
+
;;
|
|
98
|
+
|
|
99
|
+
info)
|
|
100
|
+
# info 命令选项
|
|
101
|
+
if [[ $cur == -* ]]; then
|
|
102
|
+
local info_opts="-f --field --format -s --separator"
|
|
103
|
+
COMPREPLY=($(compgen -W "$info_opts" -- "$cur"))
|
|
104
|
+
elif [[ $prev == "-f" || $prev == "--field" ]]; then
|
|
105
|
+
# 补全字段名
|
|
106
|
+
local fields="project project-path worktree-id worktree-dir branch"
|
|
107
|
+
COMPREPLY=($(compgen -W "$fields" -- "$cur"))
|
|
108
|
+
fi
|
|
109
|
+
return 0
|
|
110
|
+
;;
|
|
111
|
+
|
|
112
|
+
status|st)
|
|
113
|
+
# status 命令无参数
|
|
114
|
+
return 0
|
|
115
|
+
;;
|
|
116
|
+
|
|
117
|
+
repair)
|
|
118
|
+
# repair 命令无参数
|
|
119
|
+
return 0
|
|
120
|
+
;;
|
|
121
|
+
|
|
122
|
+
config)
|
|
123
|
+
# config 命令选项
|
|
124
|
+
if [[ $cur == -* ]]; then
|
|
125
|
+
COMPREPLY=($(compgen -W "--json" -- "$cur"))
|
|
126
|
+
fi
|
|
127
|
+
return 0
|
|
128
|
+
;;
|
|
129
|
+
|
|
130
|
+
setup)
|
|
131
|
+
# setup 命令无参数
|
|
132
|
+
return 0
|
|
133
|
+
;;
|
|
134
|
+
|
|
135
|
+
tmux)
|
|
136
|
+
# tmux [start|stop] [-f|--force]
|
|
137
|
+
if [[ $cur == -* ]]; then
|
|
138
|
+
local tmux_opts="-f --force"
|
|
139
|
+
COMPREPLY=($(compgen -W "$tmux_opts" -- "$cur"))
|
|
140
|
+
elif [[ $cword -eq 2 ]]; then
|
|
141
|
+
COMPREPLY=($(compgen -W "start stop" -- "$cur"))
|
|
142
|
+
fi
|
|
143
|
+
return 0
|
|
144
|
+
;;
|
|
145
|
+
|
|
146
|
+
release)
|
|
147
|
+
# release <version-type>
|
|
148
|
+
if [[ $cword -eq 2 ]]; then
|
|
149
|
+
COMPREPLY=($(compgen -W "patch minor major" -- "$cur"))
|
|
150
|
+
fi
|
|
151
|
+
return 0
|
|
152
|
+
;;
|
|
153
|
+
|
|
154
|
+
completion)
|
|
155
|
+
# completion [shell] [--install]
|
|
156
|
+
if [[ $cur == -* ]]; then
|
|
157
|
+
COMPREPLY=($(compgen -W "--install" -- "$cur"))
|
|
158
|
+
elif [[ $cword -eq 2 ]]; then
|
|
159
|
+
COMPREPLY=($(compgen -W "bash zsh" -- "$cur"))
|
|
160
|
+
fi
|
|
161
|
+
return 0
|
|
162
|
+
;;
|
|
163
|
+
|
|
164
|
+
list-project|lsp)
|
|
165
|
+
# list-project [--json] [-p|--paths]
|
|
166
|
+
if [[ $cur == -* ]]; then
|
|
167
|
+
local lsp_opts="--json -p --paths"
|
|
168
|
+
COMPREPLY=($(compgen -W "$lsp_opts" -- "$cur"))
|
|
169
|
+
fi
|
|
170
|
+
return 0
|
|
171
|
+
;;
|
|
172
|
+
|
|
173
|
+
todo)
|
|
174
|
+
local subcommand="${words[2]}"
|
|
175
|
+
# 第一级:补全子命令
|
|
176
|
+
if [[ $cword -eq 2 ]]; then
|
|
177
|
+
COMPREPLY=($(compgen -W "add start list ls remove archive uncomplete edit" -- "$cur"))
|
|
178
|
+
return 0
|
|
179
|
+
fi
|
|
180
|
+
# 第二级:根据子命令补全参数
|
|
181
|
+
case "$subcommand" in
|
|
182
|
+
add)
|
|
183
|
+
if [[ $cword -eq 3 && $cur != -* ]]; then
|
|
184
|
+
# 补全 todoId 类型前缀
|
|
185
|
+
COMPREPLY=($(compgen -W "feature/ bugfix/ refactor/ document/" -- "$cur"))
|
|
186
|
+
fi
|
|
187
|
+
;;
|
|
188
|
+
start)
|
|
189
|
+
if [[ $cur == -* ]]; then
|
|
190
|
+
COMPREPLY=($(compgen -W "--no-clipboard" -- "$cur"))
|
|
191
|
+
elif [[ $cword -eq 3 ]]; then
|
|
192
|
+
_colyn_todo_ids
|
|
193
|
+
fi
|
|
194
|
+
;;
|
|
195
|
+
list|ls)
|
|
196
|
+
if [[ $cur == -* ]]; then
|
|
197
|
+
COMPREPLY=($(compgen -W "--completed --archived --id-only" -- "$cur"))
|
|
198
|
+
fi
|
|
199
|
+
;;
|
|
200
|
+
remove)
|
|
201
|
+
if [[ $cur == -* ]]; then
|
|
202
|
+
COMPREPLY=($(compgen -W "-y --yes" -- "$cur"))
|
|
203
|
+
elif [[ $cword -eq 3 ]]; then
|
|
204
|
+
_colyn_todo_ids
|
|
205
|
+
fi
|
|
206
|
+
;;
|
|
207
|
+
archive)
|
|
208
|
+
if [[ $cur == -* ]]; then
|
|
209
|
+
COMPREPLY=($(compgen -W "-y --yes" -- "$cur"))
|
|
210
|
+
fi
|
|
211
|
+
;;
|
|
212
|
+
uncomplete)
|
|
213
|
+
if [[ $cword -eq 3 ]]; then
|
|
214
|
+
_colyn_todo_completed_ids
|
|
215
|
+
fi
|
|
216
|
+
;;
|
|
217
|
+
esac
|
|
218
|
+
return 0
|
|
219
|
+
;;
|
|
220
|
+
|
|
221
|
+
*)
|
|
222
|
+
# 未知命令,不提供补全
|
|
223
|
+
return 0
|
|
224
|
+
;;
|
|
225
|
+
esac
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
# 补全 worktree ID 和分支名
|
|
229
|
+
_colyn_complete_worktrees() {
|
|
230
|
+
# 尝试获取 worktree 列表(JSON 格式)
|
|
231
|
+
local worktrees_json=$(colyn list --json --no-main 2>/dev/null)
|
|
232
|
+
if [[ $? -eq 0 && -n "$worktrees_json" ]]; then
|
|
233
|
+
# 提取 ID 和分支名
|
|
234
|
+
local ids=$(echo "$worktrees_json" | grep -o '"id":[0-9]*' | cut -d: -f2)
|
|
235
|
+
local branches=$(echo "$worktrees_json" | grep -o '"branch":"[^"]*"' | cut -d'"' -f4)
|
|
236
|
+
COMPREPLY=($(compgen -W "$ids $branches" -- "$cur"))
|
|
237
|
+
fi
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
# 补全 worktree ID(仅数字)
|
|
241
|
+
_colyn_complete_worktree_ids() {
|
|
242
|
+
# 尝试获取 worktree 列表(JSON 格式)
|
|
243
|
+
local worktrees_json=$(colyn list --json --no-main 2>/dev/null)
|
|
244
|
+
if [[ $? -eq 0 && -n "$worktrees_json" ]]; then
|
|
245
|
+
# 提取 ID
|
|
246
|
+
local ids=$(echo "$worktrees_json" | grep -o '"id":[0-9]*' | cut -d: -f2)
|
|
247
|
+
COMPREPLY=($(compgen -W "$ids" -- "$cur"))
|
|
248
|
+
fi
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
# 补全待办 todo ID
|
|
252
|
+
_colyn_todo_ids() {
|
|
253
|
+
local output
|
|
254
|
+
output=$(colyn todo list --id-only 2>/dev/null)
|
|
255
|
+
if [[ -n "$output" ]]; then
|
|
256
|
+
COMPREPLY=($(compgen -W "$output" -- "$cur"))
|
|
257
|
+
fi
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
# 补全已完成 todo ID
|
|
261
|
+
_colyn_todo_completed_ids() {
|
|
262
|
+
local output
|
|
263
|
+
output=$(colyn todo list --completed --id-only 2>/dev/null)
|
|
264
|
+
if [[ -n "$output" ]]; then
|
|
265
|
+
COMPREPLY=($(compgen -W "$output" -- "$cur"))
|
|
266
|
+
fi
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
# 注册补全函数
|
|
270
|
+
complete -F _colyn_completion colyn
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
#compdef colyn
|
|
2
|
+
# Zsh completion script for colyn
|
|
3
|
+
#
|
|
4
|
+
# Installation:
|
|
5
|
+
# source /path/to/completion.zsh
|
|
6
|
+
# Or add to ~/.zshrc:
|
|
7
|
+
# echo "source /path/to/completion.zsh" >> ~/.zshrc
|
|
8
|
+
|
|
9
|
+
_colyn() {
|
|
10
|
+
local -a commands
|
|
11
|
+
commands=(
|
|
12
|
+
'init:初始化 worktree 管理结构'
|
|
13
|
+
'add:创建新的 worktree'
|
|
14
|
+
'list:列出所有 worktree'
|
|
15
|
+
'merge:合并 worktree 到主分支'
|
|
16
|
+
'update:将主分支更新到 worktree'
|
|
17
|
+
'remove:删除 worktree'
|
|
18
|
+
'checkout:在 worktree 中切换分支'
|
|
19
|
+
'info:显示当前目录的项目信息'
|
|
20
|
+
'repair:修复 worktree 状态'
|
|
21
|
+
'config:查看或更新配置'
|
|
22
|
+
'system-integration:配置 shell 集成'
|
|
23
|
+
'tmux:tmux 集成管理'
|
|
24
|
+
'release:在主分支目录执行发布流程'
|
|
25
|
+
'completion:生成 shell 自动补全脚本'
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
local curcontext="$curcontext" state line
|
|
29
|
+
typeset -A opt_args
|
|
30
|
+
|
|
31
|
+
_arguments -C \
|
|
32
|
+
'1: :->command' \
|
|
33
|
+
'*::arg:->args'
|
|
34
|
+
|
|
35
|
+
case $state in
|
|
36
|
+
command)
|
|
37
|
+
_describe 'colyn commands' commands
|
|
38
|
+
;;
|
|
39
|
+
args)
|
|
40
|
+
case $line[1] in
|
|
41
|
+
init)
|
|
42
|
+
# init 命令没有参数
|
|
43
|
+
;;
|
|
44
|
+
add)
|
|
45
|
+
# add <branch>
|
|
46
|
+
_colyn_branches
|
|
47
|
+
;;
|
|
48
|
+
list)
|
|
49
|
+
_arguments \
|
|
50
|
+
'--json[以 JSON 格式输出]' \
|
|
51
|
+
'(-p --paths)'{-p,--paths}'[只输出路径]' \
|
|
52
|
+
'--no-main[不显示主分支]'
|
|
53
|
+
;;
|
|
54
|
+
merge)
|
|
55
|
+
_arguments \
|
|
56
|
+
'1: :_colyn_worktrees' \
|
|
57
|
+
'--push[合并后自动推送]' \
|
|
58
|
+
'--no-push[合并后不推送]'
|
|
59
|
+
;;
|
|
60
|
+
update)
|
|
61
|
+
_arguments \
|
|
62
|
+
'1: :_colyn_worktrees' \
|
|
63
|
+
'--all[更新所有 worktree]' \
|
|
64
|
+
'--no-rebase[使用 merge 而不是 rebase]'
|
|
65
|
+
;;
|
|
66
|
+
remove)
|
|
67
|
+
_arguments \
|
|
68
|
+
'1: :_colyn_worktrees' \
|
|
69
|
+
'(-y --yes)'{-y,--yes}'[跳过确认]' \
|
|
70
|
+
'(-f --force)'{-f,--force}'[强制删除(忽略未提交更改)]' \
|
|
71
|
+
'(-d --delete-branch)'{-d,--delete-branch}'[同时删除本地分支]'
|
|
72
|
+
;;
|
|
73
|
+
checkout|co)
|
|
74
|
+
_arguments \
|
|
75
|
+
'1: :_colyn_worktree_ids' \
|
|
76
|
+
'2: :_colyn_branches'
|
|
77
|
+
;;
|
|
78
|
+
info)
|
|
79
|
+
_arguments \
|
|
80
|
+
'(-f --field)'{-f,--field}'[输出指定字段]:field:_colyn_info_fields' \
|
|
81
|
+
'--format[使用模板字符串格式化输出]:template:' \
|
|
82
|
+
'(-s --separator)'{-s,--separator}'[多字段时的分隔符]:separator:'
|
|
83
|
+
;;
|
|
84
|
+
repair)
|
|
85
|
+
# repair 命令无参数
|
|
86
|
+
;;
|
|
87
|
+
config)
|
|
88
|
+
_arguments \
|
|
89
|
+
'--json[以 JSON 格式输出]'
|
|
90
|
+
;;
|
|
91
|
+
system-integration)
|
|
92
|
+
# system-integration 命令无参数
|
|
93
|
+
;;
|
|
94
|
+
tmux)
|
|
95
|
+
_arguments \
|
|
96
|
+
'1: :(start stop)' \
|
|
97
|
+
'(-f --force)'{-f,--force}'[强制停止 session]'
|
|
98
|
+
;;
|
|
99
|
+
release)
|
|
100
|
+
_arguments \
|
|
101
|
+
'1: :('patch' 'minor' 'major')'
|
|
102
|
+
;;
|
|
103
|
+
completion)
|
|
104
|
+
_arguments \
|
|
105
|
+
'1: :(bash zsh)' \
|
|
106
|
+
'--install[显示安装说明]'
|
|
107
|
+
;;
|
|
108
|
+
esac
|
|
109
|
+
;;
|
|
110
|
+
esac
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
# 补全 git 分支名
|
|
114
|
+
_colyn_branches() {
|
|
115
|
+
local -a branches
|
|
116
|
+
branches=(${(f)"$(git branch -a 2>/dev/null | sed 's/^[* ]*//' | sed 's/remotes\/origin\///' | sort -u)"})
|
|
117
|
+
_describe 'branches' branches
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
# 补全 worktree ID 和分支名
|
|
121
|
+
_colyn_worktrees() {
|
|
122
|
+
local -a worktrees
|
|
123
|
+
local worktrees_json=$(colyn list --json --no-main 2>/dev/null)
|
|
124
|
+
|
|
125
|
+
if [[ $? -eq 0 && -n "$worktrees_json" ]]; then
|
|
126
|
+
# 提取 ID 和分支名
|
|
127
|
+
local -a ids branches
|
|
128
|
+
ids=(${(f)"$(echo "$worktrees_json" | grep -o '"id":[0-9]*' | cut -d: -f2)"})
|
|
129
|
+
branches=(${(f)"$(echo "$worktrees_json" | grep -o '"branch":"[^"]*"' | cut -d'"' -f4)"})
|
|
130
|
+
|
|
131
|
+
# 组合 ID 和分支名
|
|
132
|
+
local i
|
|
133
|
+
for i in {1..${#ids[@]}}; do
|
|
134
|
+
worktrees+=("${ids[$i]}:${branches[$i]}")
|
|
135
|
+
done
|
|
136
|
+
|
|
137
|
+
_describe 'worktrees' worktrees
|
|
138
|
+
fi
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
# 补全 worktree ID(仅数字)
|
|
142
|
+
_colyn_worktree_ids() {
|
|
143
|
+
local -a ids
|
|
144
|
+
local worktrees_json=$(colyn list --json --no-main 2>/dev/null)
|
|
145
|
+
|
|
146
|
+
if [[ $? -eq 0 && -n "$worktrees_json" ]]; then
|
|
147
|
+
ids=(${(f)"$(echo "$worktrees_json" | grep -o '"id":[0-9]*' | cut -d: -f2)"})
|
|
148
|
+
_describe 'worktree IDs' ids
|
|
149
|
+
fi
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
# 补全 info 命令的字段名
|
|
153
|
+
_colyn_info_fields() {
|
|
154
|
+
local -a fields
|
|
155
|
+
fields=(
|
|
156
|
+
'project:项目名称'
|
|
157
|
+
'project-path:项目路径'
|
|
158
|
+
'worktree-id:Worktree ID'
|
|
159
|
+
'worktree-dir:Worktree 目录名'
|
|
160
|
+
'branch:分支名'
|
|
161
|
+
)
|
|
162
|
+
_describe 'fields' fields
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
# 注册补全函数
|
|
166
|
+
# #compdef 指令会自动调用 _colyn 函数,不需要手动执行
|
|
167
|
+
compdef _colyn colyn
|