Skip to content

Commit

Permalink
optional -> flagGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
prasmussen committed Feb 6, 2016
1 parent 0535cc0 commit 0ede2d4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cli/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ func (self *Handler) getParser() Parser {
var parsers []Parser

for _, pattern := range self.SplitPattern() {
if isOptional(pattern) {
name := optionalName(pattern)
parser := getFlagParser(self.FlagGroups.getFlags(name))
parsers = append(parsers, parser)
if isFlagGroup(pattern) {
groupName := flagGroupName(pattern)
flags := self.FlagGroups.getFlags(groupName)
parsers = append(parsers, getFlagParser(flags))
} else if isCaptureGroup(pattern) {
parsers = append(parsers, CaptureGroupParser{pattern})
} else {
Expand Down Expand Up @@ -110,10 +110,10 @@ func isCaptureGroup(arg string) bool {
return strings.HasPrefix(arg, "<") && strings.HasSuffix(arg, ">")
}

func isOptional(arg string) bool {
func isFlagGroup(arg string) bool {
return strings.HasPrefix(arg, "[") && strings.HasSuffix(arg, "]")
}

func optionalName(s string) string {
func flagGroupName(s string) string {
return s[1:len(s) - 1]
}

0 comments on commit 0ede2d4

Please sign in to comment.