Skip to content

Commit

Permalink
feat. Add the -f|--forcecolors command line switch.
Browse files Browse the repository at this point in the history
  • Loading branch information
tamere-allo-peter committed Apr 26, 2022
1 parent b8c93c4 commit 9a5873f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ This software automatically fixes some errors and warnings reported by
`yamllint`.

```shell
usage: yamlfixer [-h] [-v] [-b] [-B BACKUPSUFFIX] [-d] [-D DIFF_FILE] [-e EXTENSIONS] [-l] [-N] [-n]
[-r LEVEL] [-j | -p | -s] [-t TABSIZE]
usage: yamlfixer [-h] [-v] [-b] [-B BACKUPSUFFIX] [-d] [-D DIFF_FILE] [-e EXTENSIONS] [-f]
[-l] [-N] [-n] [-r LEVEL] [-j | -p | -s] [-t TABSIZE]
[-c CONFIG_FILE | -C CONFIG_DATA]
[FILE_or_DIR [FILE_or_DIR ...]]

Expand All @@ -95,6 +95,7 @@ optional arguments:
-e EXTENSIONS, --ext EXTENSIONS
comma separated list of acceptable extensions when searching directories
for YAML files. Defaults to `yaml,yml,yamllint`.
-f, --forcecolors force colored output even if stream is not a TTY.
-l, --listfixers output the list of available fixers.
-N, --nosyntax don't try to fix syntax errors.
-n, --nochange don't modify anything.
Expand Down
3 changes: 3 additions & 0 deletions yamlfixer/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ def parse_commandline(argv=None):
default="yaml,yml,yamllint",
help="comma separated list of acceptable extensions when searching "
"directories for YAML files. Defaults to `%(default)s`.")
cmdline.add_argument("-f", "--forcecolors",
action="store_true",
help="force colored output even if stream is not a TTY.")
cmdline.add_argument("-l", "--listfixers",
action="store_true",
help="output the list of available fixers.")
Expand Down
2 changes: 1 addition & 1 deletion yamlfixer/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class YAMLFixerBase:
def __init__(self, arguments):
"""Saves command line arguments."""
self._out = sys.stderr
self._outisatty = self._out.isatty()
self._outisatty = self._out.isatty() or arguments.forcecolors
self.arguments = arguments

def _output(self, message, level=None):
Expand Down

0 comments on commit 9a5873f

Please sign in to comment.