| 186 | |
| 187 | @classmethod |
| 188 | def parse(class_, option_description): |
| 189 | short, long, argcount, value = None, None, 0, False |
| 190 | options, _, description = option_description.strip().partition(' ') |
| 191 | options = options.replace(',', ' ').replace('=', ' ') |
| 192 | for s in options.split(): |
| 193 | if s.startswith('--'): |
| 194 | long = s |
| 195 | elif s.startswith('-'): |
| 196 | short = s |
| 197 | else: |
| 198 | argcount = 1 |
| 199 | if argcount: |
| 200 | matched = re.findall('\[default: (.*)\]', description, flags=re.I) |
| 201 | value = matched[0] if matched else None |
| 202 | return class_(short, long, argcount, value) |
| 203 | |
| 204 | def single_match(self, left): |
| 205 | for n, pattern in enumerate(left): |