From bd223842a0198caa68bfea427b0fade76d44a585 Mon Sep 17 00:00:00 2001 From: Omri Ariav Date: Thu, 19 Feb 2026 23:48:50 +0200 Subject: [PATCH] fix(forms): use Flags().Changed() for update, reject --file + --title conflict - Use cmd.Flags().Changed() instead of empty-string checks to detect whether --title and --description were provided. This allows setting empty values to clear fields (e.g., --description ""). - Add explicit conflict guard: --file cannot be combined with --title or --description. Previously --file silently took precedence. Co-Authored-By: Claude Opus 4.6 --- cmd/forms.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cmd/forms.go b/cmd/forms.go index 438acd9..af34c9b 100644 --- a/cmd/forms.go +++ b/cmd/forms.go @@ -453,9 +453,17 @@ func runFormsUpdate(cmd *cobra.Command, args []string) error { title, _ := cmd.Flags().GetString("title") description, _ := cmd.Flags().GetString("description") + hasFile := cmd.Flags().Changed("file") + hasTitle := cmd.Flags().Changed("title") + hasDescription := cmd.Flags().Changed("description") + + if hasFile && (hasTitle || hasDescription) { + return p.PrintError(fmt.Errorf("--file cannot be combined with --title or --description")) + } + var batchReq forms.BatchUpdateFormRequest - if filePath != "" { + if hasFile { // Read batch update request from file data, err := os.ReadFile(filePath) if err != nil { @@ -465,11 +473,11 @@ func runFormsUpdate(cmd *cobra.Command, args []string) error { if err := json.Unmarshal(data, &batchReq); err != nil { return p.PrintError(fmt.Errorf("failed to parse JSON: %w", err)) } - } else if title != "" || description != "" { + } else if hasTitle || hasDescription { // Build simple update request for title/description var requests []*forms.Request - if title != "" { + if hasTitle { requests = append(requests, &forms.Request{ UpdateFormInfo: &forms.UpdateFormInfoRequest{ Info: &forms.Info{ @@ -480,7 +488,7 @@ func runFormsUpdate(cmd *cobra.Command, args []string) error { }) } - if description != "" { + if hasDescription { requests = append(requests, &forms.Request{ UpdateFormInfo: &forms.UpdateFormInfoRequest{ Info: &forms.Info{