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