From 9e7fe70edec0ebaaa4959ebb2693656e1384a74f Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Mon, 18 Apr 2011 07:39:51 +0000 Subject: [PATCH] =?utf8?q?Verhalten=20bei=20--usage=20ver=C3=A4ndert?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.brehm-online.com/svn/my-stuff/python/PyLogrotate/trunk@202 ec8d2aa5-1599-4edb-8739-2b3a1bc399aa --- LogRotateGetopts.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/LogRotateGetopts.py b/LogRotateGetopts.py index 930504c..95dfc06 100755 --- a/LogRotateGetopts.py +++ b/LogRotateGetopts.py @@ -83,11 +83,14 @@ class LogrotateOptParser(object): @type: str ''' - self.usage = "Usage: %s [options] " %(prog) + self.usage = "Usage: %s [options] \n" %(prog) ''' @ivar: the usage string in getopt help output @type: str ''' + self.usage += ( ' %s [-h|-?|--help]\n' %(prog) ) + self.usage += ( ' %s --usage\n' %(prog) ) + self.usage += ( ' %s --version' %(prog) ) self.options = None ''' @@ -218,13 +221,20 @@ class LogrotateOptParser(object): '-h', '-?', '--help', - '--usage', default = False, action = 'help', dest = 'help', help = 'shows a help message and exit' ) + group.add_option( + '--usage', + default = False, + action = 'store_true', + dest = 'usage', + help = 'Display brief usage message and exit' + ) + group.add_option( '-V', '--version', @@ -248,6 +258,10 @@ class LogrotateOptParser(object): self.options, self.args = self.parser.parse_args() self.parsed = True + if self.options.usage: + self.parser.print_usage() + sys.exit(0) + if self.options.force and self.options.configcheck: raise LogrotateOptParserError('Invalid usage of --force and ' + '--config-check.') -- 2.39.5