Merge "glance help <subcommand>: Clearly specify which options are mandatory"
This commit is contained in:
@@ -224,8 +224,12 @@ class OpenStackImagesShell(object):
|
|||||||
help=argparse.SUPPRESS,
|
help=argparse.SUPPRESS,
|
||||||
)
|
)
|
||||||
self.subcommands[command] = subparser
|
self.subcommands[command] = subparser
|
||||||
|
required_args = subparser.add_argument_group('Required arguments')
|
||||||
for (args, kwargs) in arguments:
|
for (args, kwargs) in arguments:
|
||||||
subparser.add_argument(*args, **kwargs)
|
if kwargs.get('required', False):
|
||||||
|
required_args.add_argument(*args, **kwargs)
|
||||||
|
else:
|
||||||
|
subparser.add_argument(*args, **kwargs)
|
||||||
subparser.set_defaults(func=callback)
|
subparser.set_defaults(func=callback)
|
||||||
|
|
||||||
def _add_bash_completion_subparser(self, subparsers):
|
def _add_bash_completion_subparser(self, subparsers):
|
||||||
|
@@ -600,6 +600,17 @@ class ShellTest(testutils.TestCase):
|
|||||||
self.assertEqual(glance_logger.getEffectiveLevel(), logging.DEBUG)
|
self.assertEqual(glance_logger.getEffectiveLevel(), logging.DEBUG)
|
||||||
conf.assert_called_with(level=logging.DEBUG)
|
conf.assert_called_with(level=logging.DEBUG)
|
||||||
|
|
||||||
|
def test_subcommand_help(self):
|
||||||
|
# Ensure that main works with sub command help
|
||||||
|
stdout, stderr = self.shell('help stores-delete')
|
||||||
|
|
||||||
|
expected = 'usage: glance stores-delete --store <STORE_ID> ' \
|
||||||
|
'<IMAGE_ID>\n\nDelete image from specific store.' \
|
||||||
|
'\n\nPositional arguments:\n <IMAGE_ID> ' \
|
||||||
|
'ID of image to update.\n\nRequired arguments:\n ' \
|
||||||
|
'--store <STORE_ID> Store to delete image from.\n'
|
||||||
|
self.assertEqual(expected, stdout)
|
||||||
|
|
||||||
|
|
||||||
class ShellTestWithKeystoneV3Auth(ShellTest):
|
class ShellTestWithKeystoneV3Auth(ShellTest):
|
||||||
# auth environment to use
|
# auth environment to use
|
||||||
|
Reference in New Issue
Block a user