From 954f330ace399921511cf39f22ebf157d3d7a53f Mon Sep 17 00:00:00 2001 From: Chris Lumens Date: Thu, 28 Jun 2018 10:47:32 -0400 Subject: [PATCH] Add help output to each subcommand. This is the same as the output at the top level, just trimmed down to only the options for a single subcommand. It's trigged by providing "help" or "--help" as a subcommand option. --- src/composer/cli/blueprints.py | 6 +++++- src/composer/cli/compose.py | 6 +++++- src/composer/cli/modules.py | 6 +++++- src/composer/cli/projects.py | 6 +++++- src/composer/cli/sources.py | 6 +++++- 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/composer/cli/blueprints.py b/src/composer/cli/blueprints.py index 9830e6a2..ce4cd130 100644 --- a/src/composer/cli/blueprints.py +++ b/src/composer/cli/blueprints.py @@ -21,6 +21,7 @@ import os import json from composer import http_client as client +from composer.cli.help import blueprints_help from composer.cli.utilities import argify, frozen_toml_filename, toml_filename, handle_api_result from composer.cli.utilities import packageNEVRA @@ -48,7 +49,10 @@ def blueprints_cmd(opts): "undo": blueprints_undo, "workspace": blueprints_workspace } - if opts.args[1] not in cmd_map: + if opts.args[1] == "help" or opts.args[1] == "--help": + print(blueprints_help) + return 0 + elif opts.args[1] not in cmd_map: log.error("Unknown blueprints command: %s", opts.args[1]) return 1 diff --git a/src/composer/cli/compose.py b/src/composer/cli/compose.py index ddf9748e..41424e10 100644 --- a/src/composer/cli/compose.py +++ b/src/composer/cli/compose.py @@ -21,6 +21,7 @@ import sys import json from composer import http_client as client +from composer.cli.help import compose_help from composer.cli.utilities import argify, handle_api_result, packageNEVRA def compose_cmd(opts): @@ -46,7 +47,10 @@ def compose_cmd(opts): "logs": compose_logs, "image": compose_image, } - if opts.args[1] not in cmd_map: + if opts.args == "help" or opts.args == "--help": + print(compose_help) + return 0 + elif opts.args[1] not in cmd_map: log.error("Unknown compose command: %s", opts.args[1]) return 1 diff --git a/src/composer/cli/modules.py b/src/composer/cli/modules.py index 972f32f8..25ad1e04 100644 --- a/src/composer/cli/modules.py +++ b/src/composer/cli/modules.py @@ -20,6 +20,7 @@ log = logging.getLogger("composer-cli") import json from composer import http_client as client +from composer.cli.help import modules_help def modules_cmd(opts): """Process modules commands @@ -29,7 +30,10 @@ def modules_cmd(opts): :returns: Value to return from sys.exit() :rtype: int """ - if opts.args[1] != "list": + if opts.args[1] == "help" or opts.args[1] == "--help": + print(modules_help) + return 0 + elif opts.args[1] != "list": log.error("Unknown modules command: %s", opts.args[1]) return 1 diff --git a/src/composer/cli/projects.py b/src/composer/cli/projects.py index 779fc82f..31b20418 100644 --- a/src/composer/cli/projects.py +++ b/src/composer/cli/projects.py @@ -21,6 +21,7 @@ import json import textwrap from composer import http_client as client +from composer.cli.help import projects_help def projects_cmd(opts): """Process projects commands @@ -34,7 +35,10 @@ def projects_cmd(opts): "list": projects_list, "info": projects_info, } - if opts.args[1] not in cmd_map: + if opts.args[1] == "help" or opts.args[1] == "--help": + print(projects_help) + return 0 + elif opts.args[1] not in cmd_map: log.error("Unknown projects command: %s", opts.args[1]) return 1 diff --git a/src/composer/cli/sources.py b/src/composer/cli/sources.py index c8ba3baa..6ebe0877 100644 --- a/src/composer/cli/sources.py +++ b/src/composer/cli/sources.py @@ -21,6 +21,7 @@ import os import json from composer import http_client as client +from composer.cli.help import sources_help from composer.cli.utilities import argify, handle_api_result def sources_cmd(opts): @@ -38,7 +39,10 @@ def sources_cmd(opts): "change": sources_add, "delete": sources_delete, } - if opts.args[1] not in cmd_map: + if opts.args[1] == "help" or opts.args[1] == "--help": + print(sources_help) + return 0 + elif opts.args[1] not in cmd_map: log.error("Unknown sources command: %s", opts.args[1]) return 1