gitlink-cli/shortcuts/_template
wbtiger ca17974d1f Merge PR #408: 提交pr
# Conflicts:
#	.gitignore
#	.golangci.yml
#	Makefile
#	cmd/root.go
#	internal/client/client.go
#	shortcuts/_template/template.go
#	shortcuts/branch/branch_test.go
#	shortcuts/ci/ci.go
#	shortcuts/ci/ci_test.go
#	shortcuts/common/types.go
#	shortcuts/file/file.go
#	shortcuts/file/file_test.go
#	shortcuts/issue/batch.go
#	shortcuts/issue/batch_test.go
#	shortcuts/issue/issue_test.go
#	shortcuts/label/label.go
#	shortcuts/label/label_test.go
#	shortcuts/member/member.go
#	shortcuts/member/member_test.go
#	shortcuts/milestone/milestone.go
#	shortcuts/milestone/milestone_test.go
#	shortcuts/org/org.go
#	shortcuts/org/org_test.go
#	shortcuts/pm/pm.go
#	shortcuts/pm/pm_test.go
#	shortcuts/pr/pr.go
#	shortcuts/pr/pr_test.go
#	shortcuts/register.go
#	shortcuts/register_test.go
#	shortcuts/release/release_test.go
#	shortcuts/search/search.go
#	shortcuts/search/search_test.go
#	shortcuts/user/user.go
#	shortcuts/user/user_test.go
#	shortcuts/wiki/wiki.go
#	shortcuts/wiki/wiki_test.go
#	skills/README.md
#	skills/gitlink-ci/SKILL.md
#	skills/gitlink-file/SKILL.md
#	skills/gitlink-issue/SKILL.md
#	skills/gitlink-label/SKILL.md
#	skills/gitlink-member/SKILL.md
#	skills/gitlink-org/SKILL.md
#	skills/gitlink-pm/SKILL.md
#	skills/gitlink-pr/SKILL.md
#	skills/gitlink-research-insight/SKILL.md
#	skills/gitlink-research-progress/SKILL.md
#	skills/gitlink-user/SKILL.md
#	skills/gitlink-wiki/SKILL.md
2026-07-14 22:50:17 +08:00
..
README.md feat(templates): 新增 shortcuts/_template 与 skills/_template 开发脚手架(起步资源包缺失项) 2026-07-10 16:14:27 +00:00
template.go feat(templates): 新增 shortcuts/_template 与 skills/_template 开发脚手架(起步资源包缺失项) 2026-07-10 16:14:27 +00:00
template_test.go feat(templates): 新增 shortcuts/_template 与 skills/_template 开发脚手架(起步资源包缺失项) 2026-07-10 16:14:27 +00:00

README.md

Shortcut 开发模板shortcuts/_template

对应起步资源包「Shortcut 开发模板」:新增一个 CLI 命令组的标准模板与脚手架。 目录以 _ 开头Go 工具链自动忽略,不影响构建;复制改名后即成为真实命令组。

使用方法5 步,详见 doc/dev-guide.md

# 1. 复制模板为你的命令组(例如 gadget
cp -r shortcuts/_template shortcuts/gadget
mv shortcuts/gadget/template.go shortcuts/gadget/gadget.go
mv shortcuts/gadget/template_test.go shortcuts/gadget/gadget_test.go
# 把包名 template 全部改为 gadget按需实现子命令
  1. shortcuts/register.go 注册import 你的包,并在 groups 列表加一行 {Name: "gadget", Short: tr.T("cmd.gadget.short"), Shortcuts: gadget.Shortcuts()}
  2. internal/i18n/locales/en-US.jsonzh-CN.json 中按字母序添加 cmd.gadget.short 等文案键
  3. httptest 单测(模板已含可直接改写的样例)并在两份 README 补使用示例
  4. doc/changes/ 新增一篇变更说明,make check 全绿后提 PR

模板内容

  • template.go:一个最小命令组——+listGET 带查询参数与分页)、+createPOST 必填 flag+deleteDELETE--yes 确认保护),覆盖读/写/删三种典型形态与本仓库全部惯例ResolveOwnerRepo、CallAPIWithQuery、ctx.Output 信封)
  • template_test.go:基于 net/http/httptest 的单测样例(断言请求方法、路径、查询参数、请求体;不访问真实网络)

惯例清单(评审常看的点)

  • 子命令一律 +verb 形式;写操作必须有 --yes 或等价确认保护
  • 所有网络调用经 shortcuts/common 助手,禁止在命令组内直接 http.Get
  • 输出统一走 ctx.Output(env) 信封({ok, data}),自动兼容 --format json/table/yaml--jq
  • 文案不硬编码,走 i18n 键(中英两份 locale 同步添加)
  • 涉及平台 API 行为的改动PR 描述中附生产实测复现步骤