MCPcopy Create free account
hub / github.com/docopt/docopt.go / singleMatch

Method singleMatch

docopt.go:1039–1066  ·  view source on GitHub ↗
(left *patternList)

Source from the content-addressed store, hash-verified

1037}
1038
1039func (p *pattern) singleMatch(left *patternList) (int, *pattern) {
1040 if p.t&patternArgument != 0 {
1041 for n, pat := range *left {
1042 if pat.t&patternArgument != 0 {
1043 return n, newArgument(p.name, pat.value)
1044 }
1045 }
1046 return -1, nil
1047 } else if p.t&patternCommand != 0 {
1048 for n, pat := range *left {
1049 if pat.t&patternArgument != 0 {
1050 if pat.value == p.name {
1051 return n, newCommand(p.name, true)
1052 }
1053 break
1054 }
1055 }
1056 return -1, nil
1057 } else if p.t&patternOption != 0 {
1058 for n, pat := range *left {
1059 if p.name == pat.name {
1060 return n, pat
1061 }
1062 }
1063 return -1, nil
1064 }
1065 panic("unmatched type")
1066}
1067
1068func (p *pattern) String() string {
1069 if p.t&patternOption != 0 {

Callers 1

matchMethod · 0.95

Calls 2

newArgumentFunction · 0.85
newCommandFunction · 0.85

Tested by

no test coverage detected