Merge "Calculate a suitable column width for positional arguments"
This commit is contained in:
@@ -438,6 +438,18 @@ class OpenStackIdentityShell(object):
|
|||||||
|
|
||||||
# I'm picky about my shell help.
|
# I'm picky about my shell help.
|
||||||
class OpenStackHelpFormatter(argparse.HelpFormatter):
|
class OpenStackHelpFormatter(argparse.HelpFormatter):
|
||||||
|
INDENT_BEFORE_ARGUMENTS = 6
|
||||||
|
MAX_WIDTH_ARGUMENTS = 32
|
||||||
|
|
||||||
|
def add_arguments(self, actions):
|
||||||
|
for action in filter(lambda x: not x.option_strings, actions):
|
||||||
|
for choice in action.choices:
|
||||||
|
length = len(choice) + self.INDENT_BEFORE_ARGUMENTS
|
||||||
|
if(length > self._max_help_position and
|
||||||
|
length <= self.MAX_WIDTH_ARGUMENTS):
|
||||||
|
self._max_help_position = length
|
||||||
|
super(OpenStackHelpFormatter, self).add_arguments(actions)
|
||||||
|
|
||||||
def start_section(self, heading):
|
def start_section(self, heading):
|
||||||
# Title-case the headings
|
# Title-case the headings
|
||||||
heading = '%s%s' % (heading[0].upper(), heading[1:])
|
heading = '%s%s' % (heading[0].upper(), heading[1:])
|
||||||
|
|||||||
Reference in New Issue
Block a user