Parse command line options into tabs and fields
(self)
| 57 | self._parse_options() |
| 58 | |
| 59 | def _parse_options(self): |
| 60 | """Parse command line options into tabs and fields""" |
| 61 | for group in self.parser.option_groups: |
| 62 | tab_data = { |
| 63 | 'title': group.title, |
| 64 | 'description': group.get_description() if hasattr(group, 'get_description') and group.get_description() else "", |
| 65 | 'options': [] |
| 66 | } |
| 67 | |
| 68 | for option in group.option_list: |
| 69 | field_data = { |
| 70 | 'dest': option.dest, |
| 71 | 'label': self._format_option_strings(option), |
| 72 | 'help': option.help if option.help else "", |
| 73 | 'type': option.type if hasattr(option, 'type') and option.type else 'bool', |
| 74 | 'value': '', |
| 75 | 'default': defaults.get(option.dest) if defaults.get(option.dest) else None |
| 76 | } |
| 77 | tab_data['options'].append(field_data) |
| 78 | self.fields[(group.title, option.dest)] = field_data |
| 79 | |
| 80 | self.tabs.append(tab_data) |
| 81 | |
| 82 | def _format_option_strings(self, option): |
| 83 | """Format option strings for display""" |
no test coverage detected