summaryrefslogtreecommitdiff
path: root/openstackclient/common/module.py
diff options
context:
space:
mode:
authorBrandon Palm <bapalm@us.ibm.com>2016-02-17 20:01:23 +0000
committerBrandon Palm <bapalm@us.ibm.com>2016-03-09 16:00:39 +0000
commitf0c3b4e69dc56934305442b505d5f5f68579f1f2 (patch)
treeaeb030048e99ae5559880d1353a3054d756be5ce /openstackclient/common/module.py
parent040d0c2e821a26ebbc72c1ed1a41ec94293bbce4 (diff)
downloadpython-openstackclient-f0c3b4e69dc56934305442b505d5f5f68579f1f2.tar.gz
Fixed command list
The cliff module expects an array of tuples however the array that this function was returning was an array of tuples that was also containing an array of values for the commands attached to each group and the cliff module wasn't liking it. The output now comes out looking like: | openstack.common | limits show | | | extension list | | openstack.baremetal.v1 | baremetal set | Change-Id: Ifa1c149cb5c66ba27dc72bf72d7c8f2f50e42f73 Closes-Bug: 1545609
Diffstat (limited to 'openstackclient/common/module.py')
-rw-r--r--openstackclient/common/module.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/openstackclient/common/module.py b/openstackclient/common/module.py
index a3dea5da..30c67c68 100644
--- a/openstackclient/common/module.py
+++ b/openstackclient/common/module.py
@@ -19,6 +19,7 @@ import six
import sys
from openstackclient.common import command
+from openstackclient.common import utils
class ListCommand(command.Lister):
@@ -29,9 +30,24 @@ class ListCommand(command.Lister):
def take_action(self, parsed_args):
cm = self.app.command_manager
groups = cm.get_command_groups()
-
+ groups = sorted(groups)
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):