Skip to content

Commit b1d917a

Browse files
committed
Add option to show all errors in the check command #295
Signed-off-by: Chin Yeung Li <[email protected]>
1 parent f263f6e commit b1d917a

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

USAGE.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,25 @@ check
113113

114114
::
115115

116+
--show-all Show all the errors and warning
116117
--help Show this message and exit.
117118

118119
Purpose
119120
-------
120121
Validating ABOUT files at LOCATION.
121122

123+
Options
124+
-------
125+
126+
::
127+
128+
--show-all
129+
130+
This option ask the tool to show all kind of errors found.
131+
The default behavior will only show 'CRITICAL', 'ERROR', and 'WARNING'
132+
133+
$ about check --show-all /home/project/about_files/
134+
122135

123136
gen
124137
===

src/attributecode/cmd.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,12 @@ def attrib(location, output, template, mapping, inventory, quiet):
214214

215215
@cli.command(cls=AboutCommand, short_help='LOCATION: directory')
216216
@click.argument('location', nargs=1, required=True, type=click.Path(exists=True, readable=True, resolve_path=True))
217-
def check(location):
217+
@click.option('--show-all', is_flag=True, help='Show all the errors and warning')
218+
def check(location, show_all):
218219
"""
219-
Validating ABOUT files at LOCATION.
220+
Validating ABOUT files at LOCATION. [Default: it will only shows the following
221+
level of errors: 'CRITICAL', 'ERROR', and 'WARNING'.
222+
Use the `--show-all` option to show all kind of errors.
220223
221224
LOCATION: Path to an ABOUT file or a directory containing ABOUT files.
222225
"""
@@ -229,16 +232,19 @@ def check(location):
229232
print_errors = []
230233
for severity, message in errors:
231234
sever = severities[severity]
232-
if sever in problematic_errors:
235+
if show_all:
233236
print_errors.append((msg_format % locals()))
237+
else:
238+
if sever in problematic_errors:
239+
print_errors.append((msg_format % locals()))
234240

235-
number_of_problematic_errors = len(print_errors)
241+
number_of_errors = len(print_errors)
236242

237243
for err in print_errors:
238244
print(err)
239245

240246
if print_errors:
241-
click.echo('Found %(number_of_problematic_errors)d errors' % locals())
247+
click.echo('Found %(number_of_errors)d errors' % locals())
242248
sys.exit(1)
243249
else:
244250
click.echo('No error is found.')

0 commit comments

Comments
 (0)