Merge "List required arguments in '--help' message in Ironic Client."

This commit is contained in:
Jenkins 2016-11-30 23:00:59 +00:00 committed by Gerrit Code Review
commit 9cc88fff8d
4 changed files with 44 additions and 3 deletions

View File

@ -57,8 +57,13 @@ def define_command(subparsers, command, callback, cmd_mapper):
subparser.add_argument('-h', '--help', action='help',
help=argparse.SUPPRESS)
cmd_mapper[command] = subparser
required_args = subparser.add_argument_group(_("Required arguments"))
for (args, kwargs) in arguments:
subparser.add_argument(*args, **kwargs)
if kwargs.get('required'):
required_args.add_argument(*args, **kwargs)
else:
subparser.add_argument(*args, **kwargs)
subparser.set_defaults(func=callback)

View File

@ -106,7 +106,7 @@ class ShellTest(utils.BaseTestCase):
def test_help_on_subcommand(self):
required = [
'.*?^usage: ironic chassis-show',
".*?^usage: ironic chassis-show",
".*?^Show detailed information about a chassis",
]
argstrings = [
@ -118,6 +118,36 @@ class ShellTest(utils.BaseTestCase):
self.assertThat(help_text,
matchers.MatchesRegex(r, self.re_options))
def test_required_args_on_node_create_help(self):
required = [
".*?^usage: ironic node-create",
".*?^Register a new node with the Ironic service",
".*?^Required arguments:",
]
argstrings = [
'help node-create',
]
for argstr in argstrings:
help_text = self.shell(argstr)
for r in required:
self.assertThat(help_text,
matchers.MatchesRegex(r, self.re_options))
def test_required_args_on_port_create_help(self):
required = [
".*?^usage: ironic port-create",
".*?^Create a new port",
".*?^Required arguments:",
]
argstrings = [
'help port-create',
]
for argstr in argstrings:
help_text = self.shell(argstr)
for r in required:
self.assertThat(help_text,
matchers.MatchesRegex(r, self.re_options))
def test_auth_param(self):
self.make_env(exclude='OS_USERNAME')
self.test_help()

View File

@ -179,7 +179,7 @@ def do_node_list(cc, args):
'-d', '--driver',
metavar='<driver>',
required=True,
help='Driver used to control the node [REQUIRED].')
help='Driver used to control the node.')
@cliutils.arg(
'-i', '--driver-info',
metavar='<key=value>',

View File

@ -0,0 +1,6 @@
fixes:
- |
Starting with this release the output of
commands ``ironic help node-create`` and
``ironic help port-create`` will show which
arguments are required