diff --git a/tests/test_cli.py b/tests/test_cli.py index 1e828b94..e95c6559 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -88,6 +88,18 @@ def get_start_date(watson, output): return watson.frames[frame_id].start.format('YYYY-MM-DD HH:mm:ss') +# watson help + +@pytest.mark.parametrize('cmd_name', ['add', 'start', 'stop']) +def test_show_command_help(runner, watson, cmd_name): + result = runner.invoke( + cli.help, + [cmd_name], + obj=watson) + assert result.exit_code == 0 + assert result.output.startswith('Usage: ' + cmd_name) + + # watson add @pytest.mark.parametrize('test_dt,expected', VALID_DATES_DATA) diff --git a/watson/cli.py b/watson/cli.py index 1646dc1a..fd6db842 100644 --- a/watson/cli.py +++ b/watson/cli.py @@ -158,7 +158,10 @@ def help(ctx, command): if not cmd: raise click.ClickException(u"No such command: {}".format(command)) - click.echo(cmd.get_help(ctx)) + # the passed context is that of the 'help' command, which would + # show up in the Usage: ... - message. Create the proper context: + cmd_context = click.Context(cmd, parent=ctx.parent, info_name=cmd.name) + click.echo(cmd.get_help(cmd_context)) def _start(watson, project, tags, restart=False, gap=True):