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)
| 7649 | |
| 7650 | |
| 7651 | def ParseArguments(args): |
| 7652 | """Parses the command line arguments. |
| 7653 | |
| 7654 | This may set the output format and verbosity level as side-effects. |
| 7655 | |
| 7656 | Args: |
| 7657 | args: The command line arguments: |
| 7658 | |
| 7659 | Returns: |
| 7660 | The list of filenames to lint. |
| 7661 | """ |
| 7662 | try: |
| 7663 | (opts, filenames) = getopt.getopt( |
| 7664 | args, |
| 7665 | "", |
| 7666 | [ |
| 7667 | "help", |
| 7668 | "output=", |
| 7669 | "verbose=", |
| 7670 | "v=", |
| 7671 | "version", |
| 7672 | "counting=", |
| 7673 | "filter=", |
| 7674 | "root=", |
| 7675 | "repository=", |
| 7676 | "linelength=", |
| 7677 | "extensions=", |
| 7678 | "exclude=", |
| 7679 | "recursive", |
| 7680 | "headers=", |
| 7681 | "includeorder=", |
| 7682 | "config=", |
| 7683 | "quiet", |
| 7684 | ], |
| 7685 | ) |
| 7686 | except getopt.GetoptError: |
| 7687 | PrintUsage("Invalid arguments.") |
| 7688 | |
| 7689 | verbosity = _VerboseLevel() |
| 7690 | output_format = _OutputFormat() |
| 7691 | filters = "" |
| 7692 | quiet = _Quiet() |
| 7693 | counting_style = "" |
| 7694 | recursive = False |
| 7695 | |
| 7696 | for opt, val in opts: |
| 7697 | if opt == "--help": |
| 7698 | PrintUsage(None) |
| 7699 | if opt == "--version": |
| 7700 | PrintVersion() |
| 7701 | elif opt == "--output": |
| 7702 | if val not in ("emacs", "vs7", "eclipse", "junit", "sed", "gsed"): |
| 7703 | PrintUsage( |
| 7704 | "The only allowed output formats are emacs, vs7, eclipse sed, gsed and junit." |
| 7705 | ) |
| 7706 | output_format = val |
| 7707 | elif opt == "--quiet": |
| 7708 | quiet = True |
no test coverage detected