Add validation to require group or request flags and improve error messages for request decoding failures

Author Mitja Felicijan <mitja.felicijan@gmail.com> 2026-02-05 23:33:52 +0100
Committer Mitja Felicijan <mitja.felicijan@gmail.com> 2026-02-05 23:33:52 +0100
Commit 875a9f93e6616ddb8a71238149eb1384ca177191 (patch)
-rw-r--r-- main.go 9
1 files changed, 9 insertions, 0 deletions
diff --git a/main.go b/main.go
...
94
	}
94
	}
95
	runner.ShowHeaders = *showHeaders
95
	runner.ShowHeaders = *showHeaders
96
  
96
  
  
97
	if *groupName == "" && *reqNames == "" {
  
98
		fmt.Printf("Error: -group or -req is required\n\n")
  
99
		runner.PrintHelp()
  
100
		os.Exit(0)
  
101
	}
  
102
  
97
	if envName == "" {
103
	if envName == "" {
98
		runner.PrintHelp()
104
		runner.PrintHelp()
99
		return
105
		return
...
203
  
209
  
204
		var req Request
210
		var req Request
205
		if err := valNode.Decode(&req); err != nil {
211
		if err := valNode.Decode(&req); err != nil {
  
212
			if strings.Contains(err.Error(), "invalid map key") {
  
213
				return fmt.Errorf("%sfailed to decode request %q: %w\n%sHint: Check for unquoted template variables like {{foo}} used as values%s", colorRed, name, err, colorYellow, colorReset)
  
214
			}
206
			return fmt.Errorf("%sfailed to decode request %q: %w%s", colorRed, name, err, colorReset)
215
			return fmt.Errorf("%sfailed to decode request %q: %w%s", colorRed, name, err, colorReset)
207
		}
216
		}
208
  
217
  
...