Skip to content
This repository was archived by the owner on Nov 29, 2023. It is now read-only.

Commit d48d35a

Browse files
author
Gary Kotton
committed
Ensures that help alignment is not hard coded
Fixes bug 1086770 Change-Id: I6fa3edea83783e274d78e0c0195bca69d63b6e04
1 parent 9638f75 commit d48d35a

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎quantumclient/shell.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ class HelpAction(argparse.Action):
157157
instance, passed in as the "default" value for the action.
158158
"""
159159
def __call__(self, parser, namespace, values, option_string=None):
160+
outputs = []
161+
max_len = 0
160162
app = self.default
161163
parser.print_help(app.stdout)
162164
app.stdout.write('\nCommands for API v%s:\n' % app.api_version)
@@ -165,7 +167,10 @@ def __call__(self, parser, namespace, values, option_string=None):
165167
factory = ep.load()
166168
cmd = factory(self, None)
167169
one_liner = cmd.get_description().split('\n')[0]
168-
app.stdout.write(' %-25s %s\n' % (name, one_liner))
170+
outputs.append((name, one_liner))
171+
max_len = max(len(name), max_len)
172+
for (name, one_liner) in outputs:
173+
app.stdout.write(' %s %s\n' % (name.ljust(max_len), one_liner))
169174
sys.exit(0)
170175

171176

0 commit comments

Comments
 (0)