diff options
| author | Ian Cordasco <graffatcolmingov@gmail.com> | 2016-10-25 21:34:43 +0000 |
|---|---|---|
| committer | Ian Cordasco <graffatcolmingov@gmail.com> | 2016-10-25 21:34:43 +0000 |
| commit | a9e15afbf50b3181af45a64f5736d432731eb40d (patch) | |
| tree | 6daa2e8e89a2881c7fce439a27255ebff8236137 /src/flake8 | |
| parent | 86819c153b4eafba1549ce93bc084ef9100c0ac1 (diff) | |
| parent | a71941e9fe047cc0dd586a3449cc22fec6999144 (diff) | |
| download | flake8-a9e15afbf50b3181af45a64f5736d432731eb40d.tar.gz | |
Merge branch 'master' into 'master'
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).
See merge request !90
Diffstat (limited to 'src/flake8')
| -rw-r--r-- | src/flake8/formatting/base.py | 2 | ||||
| -rw-r--r-- | src/flake8/main/options.py | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/flake8/formatting/base.py b/src/flake8/formatting/base.py index 97c60e1..32b827a 100644 --- a/src/flake8/formatting/base.py +++ b/src/flake8/formatting/base.py @@ -150,7 +150,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): diff --git a/src/flake8/main/options.py b/src/flake8/main/options.py index 47fb30c..7e9b79e 100644 --- a/src/flake8/main/options.py +++ b/src/flake8/main/options.py @@ -27,6 +27,7 @@ def register_default_options(option_manager): - ``--exit-zero`` - ``-j``/``--jobs`` - ``--output-file`` + - ``--tee`` - ``--append-config`` - ``--config`` - ``--isolated`` @@ -174,6 +175,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( |
