Skip to content

Commit

Permalink
Added RegexpList* functions
Browse files Browse the repository at this point in the history
  • Loading branch information
zealws committed Nov 29, 2015
1 parent 7978600 commit d07c944
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion values.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
{"name": "TCPAddr", "Type": "*net.TCPAddr", "plural": "TCPList", "no_value_parser": true},
{"name": "ExistingFile", "Type": "string", "plural": "ExistingFiles", "no_value_parser": true},
{"name": "ExistingDir", "Type": "string", "plural": "ExistingDirs", "no_value_parser": true},
{"name": "ExistingFileOrDir", "Type": "string", "plural": "ExistingFilesOrDirs", "no_value_parser": true}
{"name": "ExistingFileOrDir", "Type": "string", "plural": "ExistingFilesOrDirs", "no_value_parser": true},
{"name": "Regexp", "Type": "*regexp.Regexp", "plural": "RegexpList", "no_value_parser": true}
]
12 changes: 12 additions & 0 deletions values_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package kingpin
import (
"fmt"
"net"
"regexp"
"strconv"
"time"
)
Expand Down Expand Up @@ -620,3 +621,14 @@ func (p *parserMixin) ExistingFilesOrDirs() (target *[]string) {
func (p *parserMixin) ExistingFilesOrDirsVar(target *[]string) {
p.SetValue(newAccumulator(target, func(v interface{}) Value { return newExistingFileOrDirValue(v.(*string)) }))
}

// RegexpList accumulates *regexp.Regexp values into a slice.
func (p *parserMixin) RegexpList() (target *[]*regexp.Regexp) {
target = new([]*regexp.Regexp)
p.RegexpListVar(target)
return
}

func (p *parserMixin) RegexpListVar(target *[]*regexp.Regexp) {
p.SetValue(newAccumulator(target, func(v interface{}) Value { return newRegexpValue(v.(**regexp.Regexp)) }))
}

0 comments on commit d07c944

Please sign in to comment.