File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919import sys
2020
2121from openstackclient .common import command
22+ from openstackclient .common import utils
2223
2324
2425class ListCommand (command .Lister ):
@@ -29,9 +30,24 @@ class ListCommand(command.Lister):
2930 def take_action (self , parsed_args ):
3031 cm = self .app .command_manager
3132 groups = cm .get_command_groups ()
32-
33+ groups = sorted ( groups )
3334 columns = ('Command Group' , 'Commands' )
34- return (columns , ((c , cm .get_command_names (group = c )) for c in groups ))
35+
36+ commands = []
37+ for group in groups :
38+ command_names = cm .get_command_names (group )
39+ command_names = sorted (command_names )
40+
41+ if command_names != []:
42+
43+ # TODO(bapalm): Fix this when cliff properly supports
44+ # handling the detection rather than using the hard-code below.
45+ if parsed_args .formatter == 'table' :
46+ command_names = utils .format_list (command_names , "\n " )
47+
48+ commands .append ((group , command_names ))
49+
50+ return (columns , commands )
3551
3652
3753class ListModule (command .ShowOne ):
Original file line number Diff line number Diff line change @@ -48,10 +48,11 @@ def setUp(self):
4848 super (TestCommandList , self ).setUp ()
4949
5050 self .app .command_manager = mock .Mock ()
51- self .app .command_manager .get_command_groups .return_value = ['test' ]
51+ self .app .command_manager .get_command_groups .return_value = [
52+ 'openstack.common'
53+ ]
5254 self .app .command_manager .get_command_names .return_value = [
53- 'one' ,
54- 'cmd two' ,
55+ 'limits show\n extension list'
5556 ]
5657
5758 # Get the command object to test
@@ -67,12 +68,15 @@ def test_command_list_no_options(self):
6768 # containing the data to be listed.
6869 columns , data = self .cmd .take_action (parsed_args )
6970
71+ # TODO(bapalm): Adjust this when cliff properly supports
72+ # handling the detection rather than using the hard-code below.
7073 collist = ('Command Group' , 'Commands' )
7174 self .assertEqual (collist , columns )
7275 datalist = ((
73- 'test' ,
74- ['one' , 'cmd two' ],
75- ), )
76+ 'openstack.common' ,
77+ 'limits show\n extension list'
78+ ),)
79+
7680 self .assertEqual (datalist , tuple (data ))
7781
7882
Original file line number Diff line number Diff line change 1+ ---
2+ fixes :
3+ - |
4+ Fixed ``openstack command list`` to display properly
5+ [Bug `1545609 <https://bugs.launchpad.net/python-openstackclient/+bug/1545609>`_]
You can’t perform that action at this time.
0 commit comments