summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Baunton <ebaunton1@bloomberg.net>2018-06-07 16:02:04 +0100
committerEd Baunton <ebaunton1@bloomberg.net>2018-06-07 18:34:27 +0100
commitb25c31ea358986fdc5f95cf607fc75f00fb5fb78 (patch)
treee96bd461a168b322ab34c94f5499af2c6cec6414
parente36001f92d1ac3e3e40863e2683cd2baba2175fa (diff)
downloadbuildstream-b25c31ea358986fdc5f95cf607fc75f00fb5fb78.tar.gz
Implement bst help
-rw-r--r--buildstream/_frontend/cli.py18
-rw-r--r--tests/completions/completions.py1
2 files changed, 16 insertions, 3 deletions
diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py
index bc17fed87..9cd0a871c 100644
--- a/buildstream/_frontend/cli.py
+++ b/buildstream/_frontend/cli.py
@@ -189,10 +189,22 @@ def cli(context, **kwargs):
context.obj = App.create(dict(kwargs))
context.call_on_close(context.obj.cleanup)
-@cli.command(short_help="Print usage information")
+
+##################################################################
+# Help Command #
+##################################################################
+@cli.command(name="help", short_help="Print usage information",
+ context_settings={"help_option_names": []})
+@click.argument("arg", nargs=-1)
@click.pass_context
-def help(ctx):
- click.echo(ctx.parent.get_help())
+def help_command(ctx, **kwargs):
+ click.echo(ctx.parent.get_help(), err=True)
+ # TODO support bst help <command> but currently
+ # seems non obvious how to do this with click.
+ if kwargs["arg"]:
+ click.echo("\n{} {} --help for more usage on a specific command\n".format(
+ ctx.parent.info_name, " ".join(kwargs["arg"])), err=True)
+
##################################################################
# Init Command #
diff --git a/tests/completions/completions.py b/tests/completions/completions.py
index d6d0fde81..239978c84 100644
--- a/tests/completions/completions.py
+++ b/tests/completions/completions.py
@@ -9,6 +9,7 @@ MAIN_COMMANDS = [
'build ',
'checkout ',
'fetch ',
+ 'help ',
'init ',
'pull ',
'push ',