diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-06-15 10:54:30 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-06-15 10:55:46 -0400 |
commit | 9b08b9179e11ef092396662afd1a71e57ca5e528 (patch) | |
tree | 712eb9d46c56cfb7dcff0628994968e62dcbd15d /src/lib/Bcfg2 | |
parent | edf1383048bfbd117ec27fb25a74c4b02a430ecd (diff) | |
download | bcfg2-9b08b9179e11ef092396662afd1a71e57ca5e528.tar.gz bcfg2-9b08b9179e11ef092396662afd1a71e57ca5e528.tar.bz2 bcfg2-9b08b9179e11ef092396662afd1a71e57ca5e528.zip |
fixed option alignment issues
Diffstat (limited to 'src/lib/Bcfg2')
-rw-r--r-- | src/lib/Bcfg2/Options.py | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/src/lib/Bcfg2/Options.py b/src/lib/Bcfg2/Options.py index 96a99b582..bbbbec343 100644 --- a/src/lib/Bcfg2/Options.py +++ b/src/lib/Bcfg2/Options.py @@ -81,21 +81,18 @@ class Option(object): self.cook = cook def buildHelpMessage(self): - msg = '' - if self.cmd: - if not self.long: - msg = self.cmd.ljust(3) - else: - msg = self.cmd - if self.odesc: - if self.long: - msg = "%-28s" % ("%s=%s" % (self.cmd, self.odesc)) - else: - msg += '%-25s' % (self.odesc) + vals = [] + if not self.cmd: + return '' + if self.odesc: + if self.long: + vals.append("%s=%s" % (self.cmd, self.odesc)) else: - msg += '%-25s' % ('') - msg += "%s\n" % self.desc - return msg + vals.append("%s %s" % (self.cmd, self.odesc)) + else: + vals.append(self.cmd) + vals.append(self.desc) + return " %-28s %s\n" % tuple(vals) def buildGetopt(self): gstr = '' @@ -168,14 +165,15 @@ class OptionSet(dict): hlist = [] # list of _non-empty_ help messages for opt in list(self.values()): hm = opt.buildHelpMessage() - if hm != '': + if hm: hlist.append(hm) - return ' '.join(hlist) + return ''.join(hlist) def helpExit(self, msg='', code=1): if msg: print(msg) - print("Usage:\n %s" % self.buildHelpMessage()) + print("Usage:") + print(self.buildHelpMessage()) raise SystemExit(code) def parse(self, argv, do_getopt=True): |