diff options
| author | Eric N. Vander Weele <ericvw@gmail.com> | 2019-10-25 15:01:30 -0400 |
|---|---|---|
| committer | Eric N. Vander Weele <ericvw@gmail.com> | 2019-10-25 17:07:43 -0400 |
| commit | 2a5c2bb6969046b607bbb44bf5c7d2c774768d7c (patch) | |
| tree | b17f299bc2135856988c34bc251c0969a8b42277 /src/flake8 | |
| parent | e2c4b50a46e7913e55f79f328ccf1257f74b8a2a (diff) | |
| download | flake8-2a5c2bb6969046b607bbb44bf5c7d2c774768d7c.tar.gz | |
options: Split-out registration of preliminary options
This is in preparation for having separate `ArgumentParser`s for
preliminary and the remaining options.
Diffstat (limited to 'src/flake8')
| -rw-r--r-- | src/flake8/main/application.py | 1 | ||||
| -rw-r--r-- | src/flake8/main/options.py | 98 |
2 files changed, 55 insertions, 44 deletions
diff --git a/src/flake8/main/application.py b/src/flake8/main/application.py index 60b0c5c..5037293 100644 --- a/src/flake8/main/application.py +++ b/src/flake8/main/application.py @@ -50,6 +50,7 @@ class Application(object): self.option_manager = manager.OptionManager( prog="flake8", version=flake8.__version__ ) + options.register_preliminary_options(self.option_manager) options.register_default_options(self.option_manager) #: The instance of :class:`flake8.options.config.ConfigFileFinder` self.config_finder = None # type: config.ConfigFileFinder diff --git a/src/flake8/main/options.py b/src/flake8/main/options.py index 101bd1a..ad37660 100644 --- a/src/flake8/main/options.py +++ b/src/flake8/main/options.py @@ -6,12 +6,65 @@ from flake8.main import debug from flake8.main import vcs +def register_preliminary_options(option_manager): + """Register the preliminary options on our OptionManager. + + The preliminary options include: + + - ``-v``/``--verbose`` + - ``--output-file`` + - ``--append-config`` + - ``--config`` + - ``--isolated`` + """ + add_option = option_manager.add_option + + add_option( + "-v", + "--verbose", + default=0, + action="count", + help="Print more information about what is happening in flake8." + " This option is repeatable and will increase verbosity each " + "time it is repeated.", + ) + + add_option( + "--output-file", default=None, help="Redirect report to a file." + ) + + # Config file options + + add_option( + "--append-config", + action="append", + help="Provide extra config files to parse in addition to the files " + "found by Flake8 by default. These files are the last ones read " + "and so they take the highest precedence when multiple files " + "provide the same option.", + ) + + add_option( + "--config", + default=None, + help="Path to the config file that will be the authoritative config " + "source. This will cause Flake8 to ignore all other " + "configuration files.", + ) + + add_option( + "--isolated", + default=False, + action="store_true", + help="Ignore all configuration files.", + ) + + def register_default_options(option_manager): """Register the default options on our OptionManager. The default options include: - - ``-v``/``--verbose`` - ``-q``/``--quiet`` - ``--count`` - ``--diff`` @@ -32,11 +85,7 @@ def register_default_options(option_manager): - ``--enable-extensions`` - ``--exit-zero`` - ``-j``/``--jobs`` - - ``--output-file`` - ``--tee`` - - ``--append-config`` - - ``--config`` - - ``--isolated`` - ``--benchmark`` - ``--bug-report`` """ @@ -44,15 +93,6 @@ def register_default_options(option_manager): # pep8 options add_option( - "-v", - "--verbose", - default=0, - action="count", - help="Print more information about what is happening in flake8." - " This option is repeatable and will increase verbosity each " - "time it is repeated.", - ) - add_option( "-q", "--quiet", default=0, @@ -258,10 +298,6 @@ def register_default_options(option_manager): ) add_option( - "--output-file", default=None, help="Redirect report to a file." - ) - - add_option( "--tee", default=False, parse_from_config=True, @@ -269,32 +305,6 @@ def register_default_options(option_manager): help="Write to stdout and output-file.", ) - # Config file options - - add_option( - "--append-config", - action="append", - help="Provide extra config files to parse in addition to the files " - "found by Flake8 by default. These files are the last ones read " - "and so they take the highest precedence when multiple files " - "provide the same option.", - ) - - add_option( - "--config", - default=None, - help="Path to the config file that will be the authoritative config " - "source. This will cause Flake8 to ignore all other " - "configuration files.", - ) - - add_option( - "--isolated", - default=False, - action="store_true", - help="Ignore all configuration files.", - ) - # Benchmarking add_option( |
