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)
| 366 | // arg name. Used to reject embedded flag fragments and prose that the |
| 367 | // regex would otherwise capture from idiosyncratic Use strings. |
| 368 | func 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 | |
| 385 | func collectFlags(fs *pflag.FlagSet) map[string]Flag { |
| 386 | if fs == nil { |