MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / validArgName

Function validArgName

internal/cmdhelp/json.go:368–383  ·  view source on GitHub ↗

validArgName returns true if s looks like an ordinary identifier-style arg name. Used to reject embedded flag fragments and prose that the regex would otherwise capture from idiosyncratic Use strings.

(s string)

Source from the content-addressed store, hash-verified

366// arg name. Used to reject embedded flag fragments and prose that the
367// regex would otherwise capture from idiosyncratic Use strings.
368func validArgName(s string) bool {
369 if s == "" {
370 return false
371 }
372 for _, r := range s {
373 switch {
374 case r == '-' || r == '_' || r == '.' || r == '/':
375 case r >= 'a' && r <= 'z':
376 case r >= 'A' && r <= 'Z':
377 case r >= '0' && r <= '9':
378 default:
379 return false
380 }
381 }
382 return true
383}
384
385func collectFlags(fs *pflag.FlagSet) map[string]Flag {
386 if fs == nil {

Callers 1

parseArgsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected