mirror of
https://github.com/adrienverge/yamllint.git
synced 2025-02-25 18:55:20 -06:00
cli: Separate --format=auto logic
Moved the auto arg_format selection out of the main if block into a separate logic section to improve readability. No logic changes.
This commit is contained in:
parent
9e6dfacceb
commit
7246a0c800
@ -103,18 +103,22 @@ def show_problems(problems, file, args_format, no_warn):
|
||||
max_level = 0
|
||||
first = True
|
||||
|
||||
if args_format == 'auto':
|
||||
if ('GITHUB_ACTIONS' in os.environ and
|
||||
'GITHUB_WORKFLOW' in os.environ):
|
||||
args_format = 'github'
|
||||
elif supports_color():
|
||||
args_format = 'colored'
|
||||
|
||||
for problem in problems:
|
||||
max_level = max(max_level, PROBLEM_LEVELS[problem.level])
|
||||
if no_warn and (problem.level != 'error'):
|
||||
continue
|
||||
if args_format == 'parsable':
|
||||
print(Format.parsable(problem, file))
|
||||
elif args_format == 'github' or (args_format == 'auto' and
|
||||
'GITHUB_ACTIONS' in os.environ and
|
||||
'GITHUB_WORKFLOW' in os.environ):
|
||||
elif args_format == 'github':
|
||||
print(Format.github(problem, file))
|
||||
elif args_format == 'colored' or \
|
||||
(args_format == 'auto' and supports_color()):
|
||||
elif args_format == 'colored':
|
||||
if first:
|
||||
print('\033[4m%s\033[0m' % file)
|
||||
first = False
|
||||
|
Loading…
Reference in New Issue
Block a user