diff --git a/cli/dcoscli/config/main.py b/cli/dcoscli/config/main.py index 5da7ea8..07e1c99 100644 --- a/cli/dcoscli/config/main.py +++ b/cli/dcoscli/config/main.py @@ -1,8 +1,8 @@ """Get and set DCOS command line options Usage: + dcos config --info dcos config append - dcos config info dcos config prepend dcos config set dcos config show [] @@ -11,6 +11,7 @@ Usage: Options: -h, --help Show this screen + --info Show a short description of this subcommand --version Show version --index= Index into the list. The first element in the list has an index of zero @@ -59,11 +60,6 @@ def _cmds(): """ return [ - cmds.Command( - hierarchy=['config', 'info'], - arg_keys=[], - function=_info), - cmds.Command( hierarchy=['config', 'set'], arg_keys=['', ''], @@ -93,11 +89,18 @@ def _cmds(): hierarchy=['config', 'validate'], arg_keys=[], function=_validate), + + cmds.Command( + hierarchy=['config'], + arg_keys=['--info'], + function=_info), ] -def _info(): +def _info(info): """ + :param info: Whether to output a description of this subcommand + :type info: boolean :returns: process status :rtype: int """ diff --git a/cli/dcoscli/help/main.py b/cli/dcoscli/help/main.py index 6cf0bd1..6ebf42a 100644 --- a/cli/dcoscli/help/main.py +++ b/cli/dcoscli/help/main.py @@ -1,12 +1,13 @@ """Display command line usage information Usage: + dcos help --info dcos help - dcos help info Options: - --help Show this screen - --version Show version + --help Show this screen + --info Show a short description of this subcommand + --version Show version """ import dcoscli import docopt @@ -25,7 +26,7 @@ def main(): __doc__, version='dcos-help version {}'.format(dcoscli.version)) - if args['help'] and args['info']: + if args['help'] and args['--info']: emitter.publish(__doc__.split('\n')[0]) # Note: this covers --all also. # Eventually we will only show commonly used commands for help diff --git a/cli/dcoscli/marathon/main.py b/cli/dcoscli/marathon/main.py index 2a629c7..540d144 100644 --- a/cli/dcoscli/marathon/main.py +++ b/cli/dcoscli/marathon/main.py @@ -2,6 +2,7 @@ Usage: dcos marathon --config-schema + dcos marathon --info dcos marathon app add [] dcos marathon app list dcos marathon app remove [--force] @@ -16,12 +17,12 @@ Usage: dcos marathon deployment stop dcos marathon deployment watch [--max-count=] [--interval=] - dcos marathon info dcos marathon task list [] dcos marathon task show Options: -h, --help Show this screen + --info Show a short description of this subcommand --version Show version --force This flag disable checks in Marathon during update operations @@ -128,11 +129,6 @@ def _cmds(): arg_keys=[''], function=_task_show), - cmds.Command( - hierarchy=['marathon', 'info'], - arg_keys=[], - function=_info), - cmds.Command( hierarchy=['marathon', 'app', 'add'], arg_keys=[''], @@ -175,13 +171,17 @@ def _cmds(): cmds.Command( hierarchy=['marathon'], - arg_keys=['--config-schema'], + arg_keys=['--config-schema', '--info'], function=_marathon), ] -def _marathon(config_schema): +def _marathon(config_schema, info): """ + :param config_schema: Whether to output the config schema + :type config_schema: boolean + :param info: Whether to output a description of this subcommand + :type info: boolean :returns: Process status :rtype: int """ @@ -192,6 +192,8 @@ def _marathon(config_schema): 'dcoscli', 'data/config-schema/marathon.json').decode('utf-8')) emitter.publish(schema) + elif info: + _info() else: emitter.publish(options.make_generic_usage_message(__doc__)) return 1 diff --git a/cli/dcoscli/package/main.py b/cli/dcoscli/package/main.py index 2f9a0bd..64cf830 100644 --- a/cli/dcoscli/package/main.py +++ b/cli/dcoscli/package/main.py @@ -2,6 +2,7 @@ Usage: dcos package --config-schema + dcos package --info dcos package describe dcos package info dcos package install [--options= --app-id= --cli --app] @@ -13,14 +14,15 @@ Usage: dcos package update Options: + -h, --help Show this screen + --info Show a short description of this subcommand + --version Show version --all Apply the operation to all matching packages --app-id= The application id --cli Apply the operation only to the package's CLI - --help Show this screen --options= Path to a JSON file containing package installation options --app Apply the operation only to the package's application - --version Show version Configuration: [package] @@ -78,11 +80,6 @@ def _cmds(): """ return [ - cmds.Command( - hierarchy=['package', 'info'], - arg_keys=[], - function=_info), - cmds.Command( hierarchy=['package', 'sources'], arg_keys=[], @@ -121,13 +118,17 @@ def _cmds(): cmds.Command( hierarchy=['package'], - arg_keys=['--config-schema'], + arg_keys=['--config-schema', '--info'], function=_package), ] -def _package(config_schema): +def _package(config_schema, info): """ + :param config_schema: Whether to output the config schema + :type config_schema: boolean + :param info: Whether to output a description of this subcommand + :type info: boolean :returns: Process status :rtype: int """ @@ -138,6 +139,8 @@ def _package(config_schema): 'dcoscli', 'data/config-schema/package.json').decode('utf-8')) emitter.publish(schema) + elif info: + _info() else: emitter.publish(options.make_generic_usage_message(__doc__)) return 1 diff --git a/cli/dcoscli/subcommand/main.py b/cli/dcoscli/subcommand/main.py index 2c0ad7c..adc5a8f 100644 --- a/cli/dcoscli/subcommand/main.py +++ b/cli/dcoscli/subcommand/main.py @@ -2,14 +2,16 @@ Usage: dcos subcommand --config-schema + dcos subcommand --info dcos subcommand info dcos subcommand install dcos subcommand list dcos subcommand uninstall Options: - --help Show this screen - --version Show version + --help Show this screen + --info Show a short description of this subcommand + --version Show version Positional arguments: The subcommand package wheel @@ -70,19 +72,14 @@ def _cmds(): arg_keys=[], function=_list), - cmds.Command( - hierarchy=['subcommand', 'info'], - arg_keys=[], - function=_info), - cmds.Command( hierarchy=['subcommand'], - arg_keys=['--config-schema'], + arg_keys=['--config-schema', '--info'], function=_subcommand), ] -def _subcommand(config_schema): +def _subcommand(config_schema, info): """ :returns: Process status :rtype: int @@ -94,6 +91,8 @@ def _subcommand(config_schema): 'dcoscli', 'data/config-schema/subcommand.json').decode('utf-8')) emitter.publish(schema) + elif info: + _info() else: emitter.publish(options.make_generic_usage_message(__doc__)) return 1 @@ -108,7 +107,6 @@ def _info(): """ emitter.publish(__doc__.split('\n')[0]) - return 0 diff --git a/cli/tests/data/dcos.toml b/cli/tests/data/dcos.toml index 8fe33fc..4dec770 100644 --- a/cli/tests/data/dcos.toml +++ b/cli/tests/data/dcos.toml @@ -1,8 +1,8 @@ [subcommand] pip_find_links = "../dist" -[package] -sources = [ "git://github.com/mesosphere/universe.git", "https://github.com/mesosphere/universe/archive/master.zip",] -cache = "tmp/cache" [marathon] host = "localhost" port = 8080 +[package] +sources = [ "git://github.com/mesosphere/universe.git", "https://github.com/mesosphere/universe/archive/master.zip",] +cache = "tmp/cache" diff --git a/cli/tests/integrations/cli/test_config.py b/cli/tests/integrations/cli/test_config.py index 4bf1206..bf71457 100644 --- a/cli/tests/integrations/cli/test_config.py +++ b/cli/tests/integrations/cli/test_config.py @@ -23,8 +23,8 @@ def test_help(): assert stdout == b"""Get and set DCOS command line options Usage: + dcos config --info dcos config append - dcos config info dcos config prepend dcos config set dcos config show [] @@ -33,6 +33,7 @@ Usage: Options: -h, --help Show this screen + --info Show a short description of this subcommand --version Show version --index= Index into the list. The first element in the list has an index of zero @@ -45,7 +46,7 @@ Positional Arguments: def test_info(): - returncode, stdout, stderr = exec_command(['dcos', 'config', 'info']) + returncode, stdout, stderr = exec_command(['dcos', 'config', '--info']) assert returncode == 0 assert stdout == b'Get and set DCOS command line options\n' diff --git a/cli/tests/integrations/cli/test_dcos.py b/cli/tests/integrations/cli/test_dcos.py index c732391..b2f65f3 100644 --- a/cli/tests/integrations/cli/test_dcos.py +++ b/cli/tests/integrations/cli/test_dcos.py @@ -75,7 +75,7 @@ def test_dcos_config_not_a_file(): def test_log_level_flag(): returncode, stdout, stderr = exec_command( - ['dcos', '--log-level=info', 'config', 'info']) + ['dcos', '--log-level=info', 'config', '--info']) assert returncode == 0 assert stdout == b"Get and set DCOS command line options\n" @@ -84,7 +84,7 @@ def test_log_level_flag(): def test_capital_log_level_flag(): returncode, stdout, stderr = exec_command( - ['dcos', '--log-level=INFO', 'config', 'info']) + ['dcos', '--log-level=INFO', 'config', '--info']) assert returncode == 0 assert stdout == b"Get and set DCOS command line options\n" @@ -93,7 +93,7 @@ def test_capital_log_level_flag(): def test_invalid_log_level_flag(): returncode, stdout, stderr = exec_command( - ['dcos', '--log-level=blah', 'config', 'info']) + ['dcos', '--log-level=blah', 'config', '--info']) assert returncode == 1 assert stdout == (b"Log level set to an unknown value 'blah'. Valid " diff --git a/cli/tests/integrations/cli/test_help.py b/cli/tests/integrations/cli/test_help.py index 1057ccd..12a9ecb 100644 --- a/cli/tests/integrations/cli/test_help.py +++ b/cli/tests/integrations/cli/test_help.py @@ -12,18 +12,19 @@ def test_help(): assert stdout == b"""Display command line usage information Usage: + dcos help --info dcos help - dcos help info Options: - --help Show this screen - --version Show version + --help Show this screen + --info Show a short description of this subcommand + --version Show version """ assert stderr == b'' def test_info(): - returncode, stdout, stderr = exec_command(['dcos', 'help', 'info']) + returncode, stdout, stderr = exec_command(['dcos', 'help', '--info']) assert returncode == 0 assert stdout == b'Display command line usage information\n' diff --git a/cli/tests/integrations/cli/test_marathon.py b/cli/tests/integrations/cli/test_marathon.py index 772d183..e95f13a 100644 --- a/cli/tests/integrations/cli/test_marathon.py +++ b/cli/tests/integrations/cli/test_marathon.py @@ -11,6 +11,7 @@ def test_help(): Usage: dcos marathon --config-schema + dcos marathon --info dcos marathon app add [] dcos marathon app list dcos marathon app remove [--force] @@ -25,12 +26,12 @@ Usage: dcos marathon deployment stop dcos marathon deployment watch [--max-count=] [--interval=] - dcos marathon info dcos marathon task list [] dcos marathon task show Options: -h, --help Show this screen + --info Show a short description of this subcommand --version Show version --force This flag disable checks in Marathon during update operations @@ -74,7 +75,7 @@ def test_version(): def test_info(): - returncode, stdout, stderr = exec_command(['dcos', 'marathon', 'info']) + returncode, stdout, stderr = exec_command(['dcos', 'marathon', '--info']) assert returncode == 0 assert stdout == b'Deploy and manage applications on the DCOS\n' diff --git a/cli/tests/integrations/cli/test_package.py b/cli/tests/integrations/cli/test_package.py index e243dd0..21aa021 100644 --- a/cli/tests/integrations/cli/test_package.py +++ b/cli/tests/integrations/cli/test_package.py @@ -13,6 +13,7 @@ def test_package(): Usage: dcos package --config-schema + dcos package --info dcos package describe dcos package info dcos package install [--options= --app-id= --cli --app] @@ -24,14 +25,15 @@ Usage: dcos package update Options: + -h, --help Show this screen + --info Show a short description of this subcommand + --version Show version --all Apply the operation to all matching packages --app-id= The application id --cli Apply the operation only to the package's CLI - --help Show this screen --options= Path to a JSON file containing package installation options --app Apply the operation only to the package's application - --version Show version Configuration: [package] @@ -54,7 +56,7 @@ Configuration: def test_info(): - returncode, stdout, stderr = exec_command(['dcos', 'package', 'info']) + returncode, stdout, stderr = exec_command(['dcos', 'package', '--info']) assert returncode == 0 assert stdout == b'Install and manage DCOS software packages\n' diff --git a/cli/tests/integrations/cli/test_subcommand.py b/cli/tests/integrations/cli/test_subcommand.py index 3d3b4de..503972b 100644 --- a/cli/tests/integrations/cli/test_subcommand.py +++ b/cli/tests/integrations/cli/test_subcommand.py @@ -10,6 +10,40 @@ def package(): return os.environ['DCOS_TEST_WHEEL'] +def test_help(): + returncode, stdout, stderr = exec_command(['dcos', 'subcommand', '--help']) + + assert returncode == 0 + assert stdout == b"""Install and manage DCOS CLI subcommands + +Usage: + dcos subcommand --config-schema + dcos subcommand --info + dcos subcommand info + dcos subcommand install + dcos subcommand list + dcos subcommand uninstall + +Options: + --help Show this screen + --info Show a short description of this subcommand + --version Show version + +Positional arguments: + The subcommand package wheel + The name of the subcommand package +""" + assert stderr == b'' + + +def test_info(): + returncode, stdout, stderr = exec_command(['dcos', 'subcommand', '--info']) + + assert returncode == 0 + assert stdout == b'Install and manage DCOS CLI subcommands\n' + assert stderr == b'' + + def test_list_empty_subcommand(): _list_subcommands(0) diff --git a/dcos/api/subcommand.py b/dcos/api/subcommand.py index 753ddd7..2e588f0 100644 --- a/dcos/api/subcommand.py +++ b/dcos/api/subcommand.py @@ -123,7 +123,7 @@ def info(executable_path): """ out = subprocess.check_output( - [executable_path, noun(executable_path), 'info']) + [executable_path, noun(executable_path), '--info']) return out.decode('utf-8').strip()