Merge "Fixed command list"
This commit is contained in:
commit
586a038afd
@ -19,6 +19,7 @@ import six
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
from openstackclient.common import command
|
from openstackclient.common import command
|
||||||
|
from openstackclient.common import utils
|
||||||
|
|
||||||
|
|
||||||
class ListCommand(command.Lister):
|
class ListCommand(command.Lister):
|
||||||
@ -29,9 +30,24 @@ class ListCommand(command.Lister):
|
|||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
cm = self.app.command_manager
|
cm = self.app.command_manager
|
||||||
groups = cm.get_command_groups()
|
groups = cm.get_command_groups()
|
||||||
|
groups = sorted(groups)
|
||||||
columns = ('Command Group', 'Commands')
|
columns = ('Command Group', 'Commands')
|
||||||
return (columns, ((c, cm.get_command_names(group=c)) for c in groups))
|
|
||||||
|
commands = []
|
||||||
|
for group in groups:
|
||||||
|
command_names = cm.get_command_names(group)
|
||||||
|
command_names = sorted(command_names)
|
||||||
|
|
||||||
|
if command_names != []:
|
||||||
|
|
||||||
|
# TODO(bapalm): Fix this when cliff properly supports
|
||||||
|
# handling the detection rather than using the hard-code below.
|
||||||
|
if parsed_args.formatter == 'table':
|
||||||
|
command_names = utils.format_list(command_names, "\n")
|
||||||
|
|
||||||
|
commands.append((group, command_names))
|
||||||
|
|
||||||
|
return (columns, commands)
|
||||||
|
|
||||||
|
|
||||||
class ListModule(command.ShowOne):
|
class ListModule(command.ShowOne):
|
||||||
|
@ -48,10 +48,11 @@ class TestCommandList(utils.TestCommand):
|
|||||||
super(TestCommandList, self).setUp()
|
super(TestCommandList, self).setUp()
|
||||||
|
|
||||||
self.app.command_manager = mock.Mock()
|
self.app.command_manager = mock.Mock()
|
||||||
self.app.command_manager.get_command_groups.return_value = ['test']
|
self.app.command_manager.get_command_groups.return_value = [
|
||||||
|
'openstack.common'
|
||||||
|
]
|
||||||
self.app.command_manager.get_command_names.return_value = [
|
self.app.command_manager.get_command_names.return_value = [
|
||||||
'one',
|
'limits show\nextension list'
|
||||||
'cmd two',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# Get the command object to test
|
# Get the command object to test
|
||||||
@ -67,12 +68,15 @@ class TestCommandList(utils.TestCommand):
|
|||||||
# containing the data to be listed.
|
# containing the data to be listed.
|
||||||
columns, data = self.cmd.take_action(parsed_args)
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
# TODO(bapalm): Adjust this when cliff properly supports
|
||||||
|
# handling the detection rather than using the hard-code below.
|
||||||
collist = ('Command Group', 'Commands')
|
collist = ('Command Group', 'Commands')
|
||||||
self.assertEqual(collist, columns)
|
self.assertEqual(collist, columns)
|
||||||
datalist = ((
|
datalist = ((
|
||||||
'test',
|
'openstack.common',
|
||||||
['one', 'cmd two'],
|
'limits show\nextension list'
|
||||||
),)
|
),)
|
||||||
|
|
||||||
self.assertEqual(datalist, tuple(data))
|
self.assertEqual(datalist, tuple(data))
|
||||||
|
|
||||||
|
|
||||||
|
5
releasenotes/notes/bug-1545609-bdc1efc17214463b.yaml
Normal file
5
releasenotes/notes/bug-1545609-bdc1efc17214463b.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Fixed ``openstack command list`` to display properly
|
||||||
|
[Bug `1545609 <https://bugs.launchpad.net/python-openstackclient/+bug/1545609>`_]
|
Loading…
Reference in New Issue
Block a user