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