Merge pull request #105 from mesosphere/help-update

Updated style and tests for help
This commit is contained in:
José Armando García Sancio
2015-04-07 15:56:44 -07:00
3 changed files with 55 additions and 34 deletions

View File

@@ -11,7 +11,7 @@ Options:
"""
import dcoscli
import docopt
from dcos.api import emitting, options, subcommand, util
from dcos.api import cmds, emitting, options, subcommand, util
emitter = emitting.FlatEmitter()
@@ -26,30 +26,49 @@ def main():
__doc__,
version='dcos-help version {}'.format(dcoscli.version))
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
# and use --all to show, well, all commands.
elif args['help']:
directory = util.dcos_path()
commands_message = options.make_command_summary_string(
sorted(
subcommand.documentation(command_path)
for command_path
in subcommand.list_paths(directory)))
emitter.publish(
"Command line utility for the Mesosphere Datacenter Operating "
"System (DCOS). The Mesosphere DCOS is a distributed operating "
"system built around Apache Mesos. This utility provides tools "
"for easy management of a DCOS installation.\n")
emitter.publish("Available DCOS commands in {!r}:".format(directory))
emitter.publish(commands_message)
emitter.publish(
"\nGet detailed command description with 'dcos <command> --help'.")
return 0
else:
returncode, err = cmds.execute(_cmds(), args)
if err is not None:
emitter.publish(err)
emitter.publish(options.make_generic_usage_message(__doc__))
return 1
return returncode
def _cmds():
"""
:returns: All of the supported commands
:rtype: list of dcos.api.cmds.Command
"""
return [
cmds.Command(
hierarchy=['help'],
arg_keys=['--info'],
function=_help),
]
def _help(show_info):
if show_info:
emitter.publish(__doc__.split('\n')[0])
return 0
directory = util.dcos_path()
commands_message = options.make_command_summary_string(
sorted(
subcommand.documentation(command_path)
for command_path
in subcommand.list_paths(directory)))
emitter.publish(
"Command line utility for the Mesosphere Datacenter Operating\n"
"System (DCOS). The Mesosphere DCOS is a distributed operating\n"
"system built around Apache Mesos. This utility provides tools\n"
"for easy management of a DCOS installation.\n")
emitter.publish("Available DCOS commands in {!r}:".format(directory))
emitter.publish(commands_message)
emitter.publish(
"\nGet detailed command description with 'dcos <command> --help'.")
return 0

View File

@@ -10,10 +10,11 @@ def test_default():
returncode, stdout, stderr = exec_command(['dcos'])
assert returncode == 0
assert stdout == """Command line utility for \
the Mesosphere Datacenter Operating System (DCOS). The Mesosphere DCOS is \
a distributed operating system built around Apache Mesos. This utility \
provides tools for easy management of a DCOS installation.
assert stdout == """\
Command line utility for the Mesosphere Datacenter Operating
System (DCOS). The Mesosphere DCOS is a distributed operating
system built around Apache Mesos. This utility provides tools
for easy management of a DCOS installation.
Available DCOS commands in '{}':

View File

@@ -44,10 +44,11 @@ def test_list():
returncode, stdout, stderr = exec_command(['dcos', 'help'])
assert returncode == 0
assert stdout == """Command line utility for \
the Mesosphere Datacenter Operating System (DCOS). The Mesosphere DCOS is \
a distributed operating system built around Apache Mesos. This utility \
provides tools for easy management of a DCOS installation.
assert stdout == """\
Command line utility for the Mesosphere Datacenter Operating
System (DCOS). The Mesosphere DCOS is a distributed operating
system built around Apache Mesos. This utility provides tools
for easy management of a DCOS installation.
Available DCOS commands in '{}':