diff options
| author | termie <github@anarkystic.com> | 2011-03-24 12:42:46 -0700 |
|---|---|---|
| committer | termie <github@anarkystic.com> | 2011-03-24 12:42:46 -0700 |
| commit | ac44b8a9c5ed6a761793e1fa997768bd00a6c2da (patch) | |
| tree | b7a7cd88726152a200d1d57e4774855a78cda5ec /bin | |
| parent | c7ccbd7a16a546cbd0717427772691ce7d8b4da6 (diff) | |
| download | nova-ac44b8a9c5ed6a761793e1fa997768bd00a6c2da.tar.gz nova-ac44b8a9c5ed6a761793e1fa997768bd00a6c2da.tar.xz nova-ac44b8a9c5ed6a761793e1fa997768bd00a6c2da.zip | |
improve the formatting of the stack tool
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/stack | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -59,11 +59,21 @@ USAGE = """usage: stack [options] <controller> <method> [arg1=value arg2=value] def format_help(d): """Format help text, keys are labels and values are descriptions.""" + MAX_INDENT = 30 indent = max([len(k) for k in d]) + if indent > MAX_INDENT: + indent = MAX_INDENT - 6 + out = [] for k, v in d.iteritems(): - t = textwrap.TextWrapper(initial_indent=' %s ' % k.ljust(indent), - subsequent_indent=' ' * (indent + 6)) + if (len(k) + 6) > MAX_INDENT: + out.extend([' %s' % k]) + initial_indent = ' ' * (indent + 6) + else: + initial_indent = ' %s ' % k.ljust(indent) + subsequent_indent = ' ' * (indent + 6) + t = textwrap.TextWrapper(initial_indent=initial_indent, + subsequent_indent=subsequent_indent) out.extend(t.wrap(v)) return out |
