MCPcopy Create free account
hub / github.com/github/gh-aw / buildHelpfulParamError

Function buildHelpfulParamError

pkg/cli/mcp_argument_validation.go:137–155  ·  view source on GitHub ↗

buildHelpfulParamError constructs a human-readable error message that: - names each unknown parameter - suggests the closest valid parameter (if a good match is found) - directs the user to the tool's --help output

(toolName string, unknownParams []string, validParams []string)

Source from the content-addressed store, hash-verified

135// - suggests the closest valid parameter (if a good match is found)
136// - directs the user to the tool's --help output
137func buildHelpfulParamError(toolName string, unknownParams []string, validParams []string) string {
138 var sb strings.Builder
139
140 for i, param := range unknownParams {
141 if i > 0 {
142 sb.WriteString("\n")
143 }
144 fmt.Fprintf(&sb, "Unknown parameter '%s'.", param)
145 if suggestion := findSimilarParam(param, validParams); suggestion != "" {
146 fmt.Fprintf(&sb, " Did you mean '%s'?", suggestion)
147 }
148 }
149
150 if toolName != "" {
151 fmt.Fprintf(&sb, "\nRun 'agenticworkflows %s --help' for usage.", toolName)
152 }
153
154 return sb.String()
155}
156
157// findSimilarParam returns the valid parameter name most similar to unknown, or
158// an empty string if no parameter is close enough.

Callers 2

Calls 2

findSimilarParamFunction · 0.85
StringMethod · 0.45

Tested by 1