mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-05 20:46:54 +00:00
Add --tee option to split report output stream.
The --tee option allows the linter report to be written to stdout, even though it is being redirected to a file with the --output-file option. This is useful if I want to store the report in a separate file for later analysis but also be able to print the output on screen (e.g when running in a CI environment).
This commit is contained in:
parent
f82b5d62d0
commit
c782060a06
5 changed files with 43 additions and 7 deletions
|
|
@ -148,7 +148,7 @@ class BaseFormatter(object):
|
|||
"""Handle logic of whether to use an output file or print()."""
|
||||
if self.output_fd is not None:
|
||||
self.output_fd.write(output + self.newline)
|
||||
else:
|
||||
if self.output_fd is None or self.options.tee:
|
||||
print(output)
|
||||
|
||||
def write(self, line, source):
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ def register_default_options(option_manager):
|
|||
- ``--exit-zero``
|
||||
- ``-j``/``--jobs``
|
||||
- ``--output-file``
|
||||
- ``--tee``
|
||||
- ``--append-config``
|
||||
- ``--config``
|
||||
- ``--isolated``
|
||||
|
|
@ -171,6 +172,11 @@ def register_default_options(option_manager):
|
|||
help='Redirect report to a file.',
|
||||
)
|
||||
|
||||
add_option(
|
||||
'--tee', default=False, parse_from_config=True, action='store_true',
|
||||
help='Write to stdout and output-file.',
|
||||
)
|
||||
|
||||
# Config file options
|
||||
|
||||
add_option(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue