Skip to content

Commit 05e4d92

Browse files
chinyeunglipombredanne
authored andcommitted
Merge develop resolving conflicts #280
Signed-off-by: Philippe Ombredanne <[email protected]>
2 parents a7d053a + b1d917a commit 05e4d92

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
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: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -296,13 +296,22 @@ def attrib(location, output, template, mapping, inventory, quiet):
296296
@click.argument('location', nargs=1, required=True,
297297
type=click.Path(exists=True, readable=True, resolve_path=True))
298298

299+
@click.option('--show-all', is_flag=True, default=False,
300+
help='Show all errors and warnings. '
301+
'By default, running a check only reports these '
302+
'error levels: CRITICAL, ERROR, and WARNING. '
303+
'Use this option to report all errors and warning '
304+
'for any level.'
305+
)
306+
299307
@click.help_option('-h', '--help')
300308

301-
def check(location):
309+
def check(location, show_all):
302310
"""
303-
Validate .ABOUT file(s) at LOCATION.
311+
Check and validate .ABOUT file(s) at LOCATION for errors and
312+
print error messages on the terminal.
304313
305-
LOCATION: Path to a .ABOUT file or a directory tree containing .ABOUT files.
314+
LOCATION: Path to a .ABOUT file or a directory containing .ABOUT files.
306315
"""
307316
click.echo('Running aboutcode-toolkit version ' + __version__)
308317
click.echo('Checking ABOUT files...')
@@ -313,19 +322,22 @@ def check(location):
313322
print_errors = []
314323
for severity, message in errors:
315324
sever = severities[severity]
316-
if sever in problematic_errors:
317-
print_errors.append((msg_format % locals()))
325+
if show_all:
326+
print_errors.append(msg_format % locals())
327+
elif sever in problematic_errors:
328+
print_errors.append(msg_format % locals())
318329

319-
number_of_problematic_errors = len(print_errors)
330+
number_of_errors = len(print_errors)
320331

321332
for err in print_errors:
322333
print(err)
323334

324335
if print_errors:
325-
click.echo('Found %(number_of_problematic_errors)d errors' % locals())
336+
click.echo('Found {} errors.'.format(number_of_errors))
337+
# FIXME: not sure this is the right way to exit with a retrun code
326338
sys.exit(1)
327339
else:
328-
click.echo('No error is found.')
340+
click.echo('No error found.')
329341
# FIXME: return error code?
330342

331343

0 commit comments

Comments
 (0)