| 164 | } |
| 165 | |
| 166 | func parseDefaults(doc string) patternList { |
| 167 | defaults := patternList{} |
| 168 | p := regexp.MustCompile(`\n[ \t]*(-\S+?)`) |
| 169 | for _, s := range parseSection("options:", doc) { |
| 170 | // FIXME corner case "bla: options: --foo" |
| 171 | _, _, s = stringPartition(s, ":") // get rid of "options:" |
| 172 | split := p.Split("\n"+s, -1)[1:] |
| 173 | match := p.FindAllStringSubmatch("\n"+s, -1) |
| 174 | for i := range split { |
| 175 | optionDescription := match[i][1] + split[i] |
| 176 | if strings.HasPrefix(optionDescription, "-") { |
| 177 | defaults = append(defaults, parseOption(optionDescription)) |
| 178 | } |
| 179 | } |
| 180 | } |
| 181 | return defaults |
| 182 | } |
| 183 | |
| 184 | func parsePattern(source string, options *patternList) (*pattern, error) { |
| 185 | tokens := tokenListFromPattern(source) |