Make command listing default behaviour for dcos help and small grammatical fixes.

This commit is contained in:
Sunil Shah
2015-02-19 17:28:48 -08:00
parent 39f204fc0d
commit 79f6987fa5
5 changed files with 27 additions and 24 deletions

View File

@@ -1,12 +1,13 @@
""" """
Usage: Usage:
dcos help info dcos help
dcos help --all dcos help --all
dcos help info
Options: Options:
-h, --help Show this screen --help Show this screen
--version Show version --version Show version
--all Prints all the avaible commands to the standard output --all Prints all available commands to the standard output
""" """
import os import os
@@ -29,10 +30,11 @@ def main():
version='dcos-help version {}'.format(constants.version)) version='dcos-help version {}'.format(constants.version))
if args['help'] and args['info']: if args['help'] and args['info']:
emitter.publish('Display help information about DCOS') emitter.publish('Display usage information')
elif args['help'] and args['--all']: # Note: this covers --all. When --all is different,
elif args['help']:
directory = _binary_directory(os.environ[constants.DCOS_PATH_ENV]) directory = _binary_directory(os.environ[constants.DCOS_PATH_ENV])
emitter.publish("Available DCOS command in '{}':".format(directory)) emitter.publish("Available DCOS commands in '{}':".format(directory))
emitter.publish( emitter.publish(
options.make_command_summary_string( options.make_command_summary_string(
_external_command_documentation( _external_command_documentation(
@@ -101,9 +103,9 @@ def _binary_directory(dcos_path):
def _external_command_documentation(commands): def _external_command_documentation(commands):
"""Gather sub-command summary """Gather sub-command summary
:param commands: List of subcommand :param commands: List of subcommands
:type comands: list of str :type comands: list of str
:returns: Returns a list of subcommand and their summary :returns: Returns a list of subcommands and their summary
:rtype: list of (str, str) :rtype: list of (str, str)
""" """
def info(command): def info(command):

View File

@@ -1,9 +1,9 @@
""" """
Usage: Usage:
dcos [--log-level=<log-level>] <command> [<args>...] dcos [options] <command> [<args>...]
Options: Options:
-h, --help Show this screen --help Show this screen
--version Show version --version Show version
--log-level=<log-level> If set then print supplementary messages to --log-level=<log-level> If set then print supplementary messages to
stderr at or above this level. The severity stderr at or above this level. The severity
@@ -22,8 +22,8 @@ Environment Variables:
DCOS_CONFIG This environment variable points to the DCOS_CONFIG This environment variable points to the
location of the DCOS configuration file. location of the DCOS configuration file.
'dcos help --all' lists available subcommands. See 'dcos <command> --help' to 'dcos help --all' lists all available subcommands. See 'dcos <command> --help'
read about a specific subcommand. to read about a specific subcommand.
""" """
@@ -60,7 +60,7 @@ def main():
return subprocess.call([command] + argv) return subprocess.call([command] + argv)
else: else:
emitter.publish( emitter.publish(
"{!r} is not a dcos command. See 'dcos --help'.".format( "{!r} is not a dcos command. See 'dcos help'.".format(
args['<command>'])) args['<command>']))
return 1 return 1

View File

@@ -9,10 +9,10 @@ def test_help():
assert returncode == 0 assert returncode == 0
assert stdout == b"""Usage: assert stdout == b"""Usage:
dcos [--log-level=<log-level>] <command> [<args>...] dcos [options] <command> [<args>...]
Options: Options:
-h, --help Show this screen --help Show this screen
--version Show version --version Show version
--log-level=<log-level> If set then print supplementary messages to --log-level=<log-level> If set then print supplementary messages to
stderr at or above this level. The severity stderr at or above this level. The severity
@@ -31,8 +31,8 @@ Environment Variables:
DCOS_CONFIG This environment variable points to the DCOS_CONFIG This environment variable points to the
location of the DCOS configuration file. location of the DCOS configuration file.
'dcos help --all' lists available subcommands. See 'dcos <command> --help' to 'dcos help --all' lists all available subcommands. See 'dcos <command> --help'
read about a specific subcommand. to read about a specific subcommand.
""" """
assert stderr == b'' assert stderr == b''

View File

@@ -7,13 +7,14 @@ def test_help():
assert returncode == 0 assert returncode == 0
assert stdout == b"""Usage: assert stdout == b"""Usage:
dcos help info dcos help
dcos help --all dcos help --all
dcos help info
Options: Options:
-h, --help Show this screen --help Show this screen
--version Show version --version Show version
--all Prints all the avaible commands to the standard output --all Prints all available commands to the standard output
""" """
assert stderr == b'' assert stderr == b''
@@ -22,7 +23,7 @@ def test_info():
returncode, stdout, stderr = exec_command(['dcos', 'help', 'info']) returncode, stdout, stderr = exec_command(['dcos', 'help', 'info'])
assert returncode == 0 assert returncode == 0
assert stdout == b'Display help information about DCOS\n' assert stdout == b'Display usage information\n'
assert stderr == b'' assert stderr == b''
@@ -38,11 +39,11 @@ def test_list_all():
returncode, stdout, stderr = exec_command(['dcos', 'help', '--all']) returncode, stdout, stderr = exec_command(['dcos', 'help', '--all'])
assert returncode == 0 assert returncode == 0
assert stdout == """Available DCOS command in '{}': assert stdout == """Available DCOS commands in '{}':
\tapp \tDeploy and manage applications on Apache Mesos \tapp \tDeploy and manage applications on Apache Mesos
\tconfig \tGet and set DCOS command line options \tconfig \tGet and set DCOS command line options
\thelp \tDisplay help information about DCOS \thelp \tDisplay usage information
\tmarathon \tDeploy and manage applications on Apache Mesos \tmarathon \tDeploy and manage applications on Apache Mesos
\tpackage \tInstall and manage DCOS software packages \tpackage \tInstall and manage DCOS software packages

View File

@@ -1,6 +1,6 @@
[package] [package]
cache = "tmp/cache"
sources = [ "git://github.com/mesosphere/universe.git",] sources = [ "git://github.com/mesosphere/universe.git",]
cache = "tmp/cache"
[marathon] [marathon]
host = "localhost" host = "localhost"
port = 8080 port = 8080