diff options
author | Ian Cordasco <graffatcolmingov@gmail.com> | 2014-12-26 21:34:32 -0600 |
---|---|---|
committer | Ian Cordasco <graffatcolmingov@gmail.com> | 2014-12-26 21:34:32 -0600 |
commit | ad0f7c9575ed9d56fd72680b54a385915d7ef9f5 (patch) | |
tree | 238f5d0dd3891641d85873c062baadf4676fd6ee /flake8/engine.py | |
parent | 07677578b49b5841771043e9803cd634fd86aab4 (diff) | |
download | flake8-feature/output-file.tar.gz |
Add --output-file optionfeature/output-file
Closes #15
Diffstat (limited to 'flake8/engine.py')
-rw-r--r-- | flake8/engine.py | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/flake8/engine.py b/flake8/engine.py index eaac9a7..85d59fe 100644 --- a/flake8/engine.py +++ b/flake8/engine.py @@ -5,6 +5,7 @@ import platform import pep8 from flake8 import __version__ +from flake8 import callbacks from flake8.reporter import multiprocessing, BaseQReport, QueueReport from flake8.util import OrderedSet, is_windows, is_using_stdin @@ -35,19 +36,6 @@ def _register_extensions(): return extensions, parser_hooks, options_hooks -def _install_hook_cb(option, option_str, value, parser): - # For now, there's no way to affect a change in how pep8 processes - # options. If no args are provided and there's no config file present, - # it will error out because no input was provided. To get around this, - # when we're using --install-hook, we'll say that there were arguments so - # we can actually attempt to install the hook. - # See: https://gitlab.com/pycqa/flake8/issues/2 and - # https://github.com/jcrocholl/pep8/blob/4c5bf00cb613be617c7f48d3b2b82a1c7b895ac1/pep8.py#L1912 - # for more context. - parser.values.install_hook = True - parser.rargs.append('.') - - def get_parser(): """This returns an instance of optparse.OptionParser with all the extensions registered and options set. This wraps ``pep8.get_parser``. @@ -78,7 +66,11 @@ def get_parser(): parser.add_option('--install-hook', default=False, dest='install_hook', help='Install the appropriate hook for this ' 'repository.', action='callback', - callback=_install_hook_cb) + callback=callbacks.install_vcs_hook) + parser.add_option('--output-file', default=None, + help='Redirect report to a file.', + type='string', nargs=1, action='callback', + callback=callbacks.redirect_stdout) return parser, options_hooks |