From a96df4d6288548bc824724b545ff2a9a277b33bf Mon Sep 17 00:00:00 2001 From: Rogee Date: Fri, 12 Sep 2025 10:24:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=20enum=20=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E7=9A=84=E5=B8=AE=E5=8A=A9=E6=96=87=E6=A1=A3=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AF=A6=E7=BB=86=E7=9A=84=E6=A0=87=E5=BF=97?= =?UTF-8?q?=E5=92=8C=E8=A1=8C=E4=B8=BA=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/gen_enum.go | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/cmd/gen_enum.go b/cmd/gen_enum.go index 76d5223..8bc774c 100644 --- a/cmd/gen_enum.go +++ b/cmd/gen_enum.go @@ -16,9 +16,28 @@ import ( func CommandGenEnum(root *cobra.Command) { cmd := &cobra.Command{ - Use: "enum", - Aliases: []string{"e"}, - Short: "Generate enums", + Use: "enum", + Aliases: []string{"e"}, + Short: "Generate enums", + Long: `Generate enums from Go files that contain both ENUM(...) and swagger:enum. + +Scans the project (recursively) for matching files and writes a corresponding +*.gen.go per file with helpers. + +Flags: +- -f, --flag Generate flag.Value support (default: true) +- -m, --marshal Generate JSON marshal/unmarshal methods +- -s, --sql Generate database/sql helpers (int, null types) (default: true) + +Behavior: +- Always generates Names() and Values() +- With --marshal: adds JSON encoding/decoding +- With --flag: adds flag.Value support +- With --sql: adds SQL driver, int, NullInt, NullString helpers + +Examples: + atomctl gen enum -m -s + atomctl gen enum --flag=false`, RunE: commandGenEnumE, PostRunE: commandGenProviderE, }