diff options
-rw-r--r-- | src/lib/Bcfg2/Options.py | 32 | ||||
-rwxr-xr-x | src/sbin/bcfg2-admin | 1 | ||||
-rwxr-xr-x | src/sbin/bcfg2-crypt | 2 | ||||
-rwxr-xr-x | src/sbin/bcfg2-info | 6 |
4 files changed, 20 insertions, 21 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): diff --git a/src/sbin/bcfg2-admin b/src/sbin/bcfg2-admin index 44c6c5a44..9b28d9bd5 100755 --- a/src/sbin/bcfg2-admin +++ b/src/sbin/bcfg2-admin @@ -80,7 +80,6 @@ def main(): mode.bcore.shutdown() else: log.error("Unknown mode %s" % setup['args'][0]) - print("Usage:\n %s" % setup.buildHelpMessage()) print(create_description()) raise SystemExit(1) diff --git a/src/sbin/bcfg2-crypt b/src/sbin/bcfg2-crypt index 7f79c8ec2..17f90ca27 100755 --- a/src/sbin/bcfg2-crypt +++ b/src/sbin/bcfg2-crypt @@ -242,7 +242,7 @@ def main(): optinfo.update(Bcfg2.Options.CRYPT_OPTIONS) optinfo.update(Bcfg2.Options.CLI_COMMON_OPTIONS) setup = Bcfg2.Options.OptionParser(optinfo) - setup.hm = "Usage: bcfg2-crypt [options] <filename>\nOptions:\n %s" % \ + setup.hm = " bcfg2-crypt [options] <filename>\nOptions:\n%s" % \ setup.buildHelpMessage() setup.parse(sys.argv[1:]) diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info index 37e9d4371..5303aa02b 100755 --- a/src/sbin/bcfg2-info +++ b/src/sbin/bcfg2-info @@ -631,8 +631,10 @@ if __name__ == '__main__': optinfo.update(Bcfg2.Options.CLI_COMMON_OPTIONS) optinfo.update(Bcfg2.Options.SERVER_COMMON_OPTIONS) setup = Bcfg2.Options.OptionParser(optinfo) - setup.hm = "Usage:\n %s\n%s" % (setup.buildHelpMessage(), - USAGE) + setup.hm = "\n".join([" bcfg2-info [options] [command <command args>]", + "Options:", + setup.buildHelpMessage(), + USAGE]) setup.parse(sys.argv[1:]) if setup['args'] and setup['args'][0] == 'help': |