Skip to content

Commit 9e1f195

Browse files
committed
Revert to using AboutCommand for Click bug
Signed-off-by: Philippe Ombredanne <[email protected]>
1 parent b2f5c41 commit 9e1f195

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/attributecode/cmd.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,22 @@
6868
''' % locals()
6969

7070

71-
reportable_errors = [u'CRITICAL', u'ERROR', u'WARNING']
72-
7371

7472
def print_version():
7573
click.echo('Running aboutcode-toolkit version ' + __version__)
7674

7775

76+
class AboutCommand(click.Command):
77+
def main(self, args=None, prog_name=None, complete_var=None,
78+
standalone_mode=True, **extra):
79+
"""
80+
Workaround click bug https://github.com/mitsuhiko/click/issues/365
81+
"""
82+
return AboutCommand.main(
83+
self, args=args, prog_name=self.name,
84+
complete_var=complete_var, standalone_mode=standalone_mode, **extra)
85+
86+
7887
# we define a main entry command with subcommands
7988
@click.group(name='about')
8089
@click.version_option(version=__version__, prog_name=prog_name, message=intro)
@@ -109,7 +118,7 @@ def validate_filter(ctx, param, value):
109118
return kvals
110119

111120

112-
@cli.command(cls=click.Command,
121+
@cli.command(cls=AboutCommand,
113122
short_help='Collect .ABOUT files and write an inventory as CSV or JSON.')
114123

115124
@click.argument('location',
@@ -218,7 +227,7 @@ def inventory(location, output, mapping, mapping_file,
218227
# gen subcommand
219228
######################################################################
220229

221-
@cli.command(cls=click.Command,
230+
@cli.command(cls=AboutCommand,
222231
short_help='Generate .ABOUT files from an inventory as CSV or JSON.')
223232

224233
@click.argument('location',
@@ -329,7 +338,7 @@ def validate_variables(ctx, param, value):
329338
return kvals
330339

331340

332-
@cli.command(cls=click.Command,
341+
@cli.command(cls=AboutCommand,
333342
short_help='Generate an attribution document from .ABOUT files.')
334343

335344
@click.argument('location',
@@ -431,7 +440,7 @@ def attrib(location, output, template, variable,
431440
# check subcommand
432441
######################################################################
433442

434-
@cli.command(cls=click.Command,
443+
@cli.command(cls=AboutCommand,
435444
short_help='Validate that the format of .ABOUT files is correct.')
436445

437446
@click.argument('location',

0 commit comments

Comments
 (0)