diff options
| author | Alex Flint <[email protected]> | 2019-04-14 18:24:59 -0700 |
|---|---|---|
| committer | Alex Flint <[email protected]> | 2019-04-14 18:24:59 -0700 |
| commit | e86673b20acd96fe6856ddd7b1ba5f1ef7624c98 (patch) | |
| tree | 1c80d52ea7f5ed9111d82e419dc392e871772f49 /parse.go | |
| parent | 9edf2ebc956a1b434fb58ef09c361377754a80d6 (diff) | |
restore process as a free func
Diffstat (limited to 'parse.go')
| -rw-r--r-- | parse.go | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -249,18 +249,18 @@ func (p *Parser) Parse(args []string) error { } // Process all command line arguments - return p.process(args) + return process(p.specs, args) } // process goes through arguments one-by-one, parses them, and assigns the result to // the underlying struct field -func (p *Parser) process(args []string) error { +func process(specs []*spec, args []string) error { // track the options we have seen wasPresent := make(map[*spec]bool) // construct a map from --option to spec optionMap := make(map[string]*spec) - for _, spec := range p.specs { + for _, spec := range specs { if spec.positional { continue } @@ -273,7 +273,7 @@ func (p *Parser) process(args []string) error { } // deal with environment vars - for _, spec := range p.specs { + for _, spec := range specs { if spec.env == "" { continue } @@ -387,7 +387,7 @@ func (p *Parser) process(args []string) error { } // process positionals - for _, spec := range p.specs { + for _, spec := range specs { if !spec.positional { continue } @@ -414,7 +414,7 @@ func (p *Parser) process(args []string) error { } // finally check that all the required args were provided - for _, spec := range p.specs { + for _, spec := range specs { if spec.required && !wasPresent[spec] { name := spec.long if !spec.positional { |
