Skip to content

Commit 3b669c8

Browse files
committed
Merge pull request #132 from Kuniwak/support-format
Support --format option
2 parents 1b69989 + 0c1a8db commit 3b669c8

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

vint/linting/cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ def _build_argparser(self):
7474
parser.add_argument('-c', '--color', action='store_true', help='colorize output when possible')
7575
parser.add_argument('-j', '--json', action='store_true', help='output json style')
7676
parser.add_argument('-t', '--stat', action='store_true', help='output statistic info')
77+
parser.add_argument('-f', '--format', help='set output format')
7778
parser.add_argument('files', nargs='*', help='file or directory path to lint')
7879

7980
return parser

vint/linting/config/config_cmdargs_source.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def _build_config_dict(self, env):
2020
config_dict = self._normalize_verbose(env, config_dict)
2121
config_dict = self._normalize_severity(env, config_dict)
2222
config_dict = self._normalize_max_violations(env, config_dict)
23+
config_dict = self._normalize_format(env, config_dict)
2324

2425
return config_dict
2526

@@ -54,6 +55,10 @@ def _normalize_max_violations(self, env, config_dict):
5455
return self._pass_config_by_key('max-violations', env, config_dict)
5556

5657

58+
def _normalize_format(self, env, config_dict):
59+
return self._pass_config_by_key('format', env, config_dict)
60+
61+
5762
def _normalize_severity(self, env, config_dict):
5863
env_cmdargs = env['cmdargs']
5964
config_dict_cmdargs = config_dict['cmdargs']

vint/linting/formatter/formatter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ def __init__(self, config_dict):
2323
else:
2424
cmdargs = {}
2525

26-
if 'format' in cmdargs:
26+
if 'format' in cmdargs and cmdargs['format'] is not None:
2727
self._format = cmdargs['format']
2828
else:
2929
self._format = DEFAULT_FORMAT
3030

31-
if 'color' in cmdargs:
31+
if 'color' in cmdargs and cmdargs['color'] is not None:
3232
self._should_be_colorized = cmdargs['color']
3333
else:
3434
self._should_be_colorized = False

0 commit comments

Comments
 (0)