diff options
| author | Jenkins <jenkins@review.openstack.org> | 2014-07-25 13:37:06 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2014-07-25 13:37:06 +0000 |
| commit | 1d7bd16711600a082a7230650523e54d4cd98801 (patch) | |
| tree | b63f874877ed60922ae0be0436b0019f71e84c02 /keystoneclient/shell.py | |
| parent | e58f7999f9011c7810b61483f8389713dfa7c72a (diff) | |
| parent | a31cc3293eaeecf7494c226b2211fd0f219d4bea (diff) | |
| download | python-keystoneclient-1d7bd16711600a082a7230650523e54d4cd98801.tar.gz | |
Merge "Calculate a suitable column width for positional arguments"
Diffstat (limited to 'keystoneclient/shell.py')
| -rw-r--r-- | keystoneclient/shell.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/keystoneclient/shell.py b/keystoneclient/shell.py index 1305c89..61b93e9 100644 --- a/keystoneclient/shell.py +++ b/keystoneclient/shell.py @@ -438,6 +438,18 @@ class OpenStackIdentityShell(object): # I'm picky about my shell help. 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): # Title-case the headings heading = '%s%s' % (heading[0].upper(), heading[1:]) |
