From 75b4758c9525aa087dce2343b8d217f840b3a2f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Verg=C3=A9?= Date: Wed, 20 Jan 2016 18:36:18 +0100 Subject: [PATCH] cli: 'standard' format: Print filename only when error --- yamllint/cli.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/yamllint/cli.py b/yamllint/cli.py index cc4d308..cbe3b8d 100644 --- a/yamllint/cli.py +++ b/yamllint/cli.py @@ -94,24 +94,26 @@ def run(argv): return_code = 0 for file in find_files_recursively(args.files): - if args.format != 'parsable': - print('\033[4m%s\033[0m' % file) - try: + first = True with open(file) as f: for problem in lint(f, conf): if args.format == 'parsable': print(Format.parsable(problem, file)) else: + if first: + print('\033[4m%s\033[0m' % file) + first = False + print(Format.standard(problem, file)) if return_code == 0 and problem.level == 'error': return_code = 1 + + if not first and args.format != 'parsable': + print('') except EnvironmentError as e: print(e) return_code = -1 - if args.format != 'parsable': - print('') - sys.exit(return_code)