feat: 增强命令帮助文档,添加详细说明和示例

This commit is contained in:
Rogee
2025-09-12 10:33:57 +08:00
parent a96df4d628
commit ee15e0932a
17 changed files with 217 additions and 52 deletions

View File

@@ -10,11 +10,20 @@ import (
)
func CommandFmt(root *cobra.Command) {
cmd := &cobra.Command{
Use: "fmt",
Short: "fmt codes",
RunE: commandFmtE,
}
cmd := &cobra.Command{
Use: "fmt",
Short: "fmt codes",
Long: `使用 gofumpt -extra 对代码进行格式化;若本机未安装,将自动 go install mvdan.cc/gofumpt@latest。
Flags:
- --check 仅检查不写入,输出未格式化文件列表
- --path 指定格式化路径(默认 .
说明:
- 正常格式化等价于gofumpt -l -extra -w <path>
- 检查模式等价于gofumpt -l -extra <path>`,
RunE: commandFmtE,
}
cmd.Flags().Bool("check", false, "Check formatting without writing changes")
cmd.Flags().String("path", ".", "Path to format (default .)")