Switch from info to --info globally.

This commit is contained in:
Connor Doyle
2015-04-06 12:12:26 -07:00
parent b1d5634a15
commit 3f557c4bb0
13 changed files with 102 additions and 56 deletions

View File

@@ -1,8 +1,8 @@
"""Get and set DCOS command line options
Usage:
dcos config --info
dcos config append <name> <value>
dcos config info
dcos config prepend <name> <value>
dcos config set <name> <value>
dcos config show [<name>]
@@ -11,6 +11,7 @@ Usage:
Options:
-h, --help Show this screen
--info Show a short description of this subcommand
--version Show version
--index=<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=['<name>', '<value>'],
@@ -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
"""

View File

@@ -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

View File

@@ -2,6 +2,7 @@
Usage:
dcos marathon --config-schema
dcos marathon --info
dcos marathon app add [<app-resource>]
dcos marathon app list
dcos marathon app remove [--force] <app-id>
@@ -16,12 +17,12 @@ Usage:
dcos marathon deployment stop <deployment-id>
dcos marathon deployment watch [--max-count=<max-count>]
[--interval=<interval>] <deployment-id>
dcos marathon info
dcos marathon task list [<app-id>]
dcos marathon task show <task-id>
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=['<task-id>'],
function=_task_show),
cmds.Command(
hierarchy=['marathon', 'info'],
arg_keys=[],
function=_info),
cmds.Command(
hierarchy=['marathon', 'app', 'add'],
arg_keys=['<app-resource>'],
@@ -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

View File

@@ -2,6 +2,7 @@
Usage:
dcos package --config-schema
dcos package --info
dcos package describe <package_name>
dcos package info
dcos package install [--options=<file> --app-id=<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=<app-id> The application id
--cli Apply the operation only to the package's CLI
--help Show this screen
--options=<file> 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

View File

@@ -2,14 +2,16 @@
Usage:
dcos subcommand --config-schema
dcos subcommand --info
dcos subcommand info
dcos subcommand install <package>
dcos subcommand list
dcos subcommand uninstall <package_name>
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:
<package> 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

View File

@@ -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"

View File

@@ -23,8 +23,8 @@ def test_help():
assert stdout == b"""Get and set DCOS command line options
Usage:
dcos config --info
dcos config append <name> <value>
dcos config info
dcos config prepend <name> <value>
dcos config set <name> <value>
dcos config show [<name>]
@@ -33,6 +33,7 @@ Usage:
Options:
-h, --help Show this screen
--info Show a short description of this subcommand
--version Show version
--index=<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'

View File

@@ -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 "

View File

@@ -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'

View File

@@ -11,6 +11,7 @@ def test_help():
Usage:
dcos marathon --config-schema
dcos marathon --info
dcos marathon app add [<app-resource>]
dcos marathon app list
dcos marathon app remove [--force] <app-id>
@@ -25,12 +26,12 @@ Usage:
dcos marathon deployment stop <deployment-id>
dcos marathon deployment watch [--max-count=<max-count>]
[--interval=<interval>] <deployment-id>
dcos marathon info
dcos marathon task list [<app-id>]
dcos marathon task show <task-id>
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'

View File

@@ -13,6 +13,7 @@ def test_package():
Usage:
dcos package --config-schema
dcos package --info
dcos package describe <package_name>
dcos package info
dcos package install [--options=<file> --app-id=<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=<app-id> The application id
--cli Apply the operation only to the package's CLI
--help Show this screen
--options=<file> 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'

View File

@@ -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 <package>
dcos subcommand list
dcos subcommand uninstall <package_name>
Options:
--help Show this screen
--info Show a short description of this subcommand
--version Show version
Positional arguments:
<package> The subcommand package wheel
<package_name> 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)

View File

@@ -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()