summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Kotton <gkotton@redhat.com>2012-12-05 12:17:00 +0000
committerGary Kotton <gkotton@redhat.com>2012-12-05 12:17:00 +0000
commitd48d35aa9bb1ef38714d7b8eb7859fc59a5df0ec (patch)
tree56cb1223bf0758147bcb76bd4021525d03760c5c
parent9638f754cee506c3d6a69aa619fcce187ed1545b (diff)
downloadpython-neutronclient-d48d35aa9bb1ef38714d7b8eb7859fc59a5df0ec.tar.gz
Ensures that help alignment is not hard coded
Fixes bug 1086770 Change-Id: I6fa3edea83783e274d78e0c0195bca69d63b6e04
-rw-r--r--quantumclient/shell.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/quantumclient/shell.py b/quantumclient/shell.py
index 6e0ebc1..88504eb 100644
--- a/quantumclient/shell.py
+++ b/quantumclient/shell.py
@@ -157,6 +157,8 @@ class HelpAction(argparse.Action):
instance, passed in as the "default" value for the action.
"""
def __call__(self, parser, namespace, values, option_string=None):
+ outputs = []
+ max_len = 0
app = self.default
parser.print_help(app.stdout)
app.stdout.write('\nCommands for API v%s:\n' % app.api_version)
@@ -165,7 +167,10 @@ class HelpAction(argparse.Action):
factory = ep.load()
cmd = factory(self, None)
one_liner = cmd.get_description().split('\n')[0]
- app.stdout.write(' %-25s %s\n' % (name, one_liner))
+ outputs.append((name, one_liner))
+ max_len = max(len(name), max_len)
+ for (name, one_liner) in outputs:
+ app.stdout.write(' %s %s\n' % (name.ljust(max_len), one_liner))
sys.exit(0)