Parses the command line arguments. This may set the output format and verbosity level as side-effects. Args: args: The command line arguments: Returns: The list of filenames to lint.
(args)
| 6725 | |
| 6726 | |
| 6727 | def ParseArguments(args): |
| 6728 | """Parses the command line arguments. |
| 6729 | |
| 6730 | This may set the output format and verbosity level as side-effects. |
| 6731 | |
| 6732 | Args: |
| 6733 | args: The command line arguments: |
| 6734 | |
| 6735 | Returns: |
| 6736 | The list of filenames to lint. |
| 6737 | """ |
| 6738 | try: |
| 6739 | (opts, filenames) = getopt.getopt(args, '', ['help', 'output=', 'verbose=', |
| 6740 | 'v=', |
| 6741 | 'version', |
| 6742 | 'counting=', |
| 6743 | 'filter=', |
| 6744 | 'root=', |
| 6745 | 'repository=', |
| 6746 | 'linelength=', |
| 6747 | 'extensions=', |
| 6748 | 'exclude=', |
| 6749 | 'recursive', |
| 6750 | 'headers=', |
| 6751 | 'includeorder=', |
| 6752 | 'quiet']) |
| 6753 | except getopt.GetoptError: |
| 6754 | PrintUsage('Invalid arguments.') |
| 6755 | |
| 6756 | verbosity = _VerboseLevel() |
| 6757 | output_format = _OutputFormat() |
| 6758 | filters = '' |
| 6759 | quiet = _Quiet() |
| 6760 | counting_style = '' |
| 6761 | recursive = False |
| 6762 | |
| 6763 | for (opt, val) in opts: |
| 6764 | if opt == '--help': |
| 6765 | PrintUsage(None) |
| 6766 | if opt == '--version': |
| 6767 | PrintVersion() |
| 6768 | elif opt == '--output': |
| 6769 | if val not in ('emacs', 'vs7', 'eclipse', 'junit', 'sed', 'gsed'): |
| 6770 | PrintUsage('The only allowed output formats are emacs, vs7, eclipse ' |
| 6771 | 'sed, gsed and junit.') |
| 6772 | output_format = val |
| 6773 | elif opt == '--quiet': |
| 6774 | quiet = True |
| 6775 | elif opt == '--verbose' or opt == '--v': |
| 6776 | verbosity = int(val) |
| 6777 | elif opt == '--filter': |
| 6778 | filters = val |
| 6779 | if not filters: |
| 6780 | PrintCategories() |
| 6781 | elif opt == '--counting': |
| 6782 | if val not in ('total', 'toplevel', 'detailed'): |
| 6783 | PrintUsage('Valid counting options are total, toplevel, and detailed') |
| 6784 | counting_style = val |
no test coverage detected