mirror of
https://github.com/PyCQA/flake8.git
synced 2026-03-30 18:56:53 +00:00
options: Split-out registration of preliminary options
This is in preparation for having separate `ArgumentParser`s for preliminary and the remaining options.
This commit is contained in:
parent
e2c4b50a46
commit
2a5c2bb696
3 changed files with 56 additions and 44 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,26 +85,13 @@ def register_default_options(option_manager):
|
|||
- ``--enable-extensions``
|
||||
- ``--exit-zero``
|
||||
- ``-j``/``--jobs``
|
||||
- ``--output-file``
|
||||
- ``--tee``
|
||||
- ``--append-config``
|
||||
- ``--config``
|
||||
- ``--isolated``
|
||||
- ``--benchmark``
|
||||
- ``--bug-report``
|
||||
"""
|
||||
add_option = option_manager.add_option
|
||||
|
||||
# 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",
|
||||
|
|
@ -257,10 +297,6 @@ def register_default_options(option_manager):
|
|||
" (Default: %(default)s)",
|
||||
)
|
||||
|
||||
add_option(
|
||||
"--output-file", default=None, help="Redirect report to a file."
|
||||
)
|
||||
|
||||
add_option(
|
||||
"--tee",
|
||||
default=False,
|
||||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ def optmanager():
|
|||
prog='flake8',
|
||||
version='3.0.0',
|
||||
)
|
||||
options.register_preliminary_options(option_manager)
|
||||
options.register_default_options(option_manager)
|
||||
return option_manager
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue