]> Frank Brehm's Git Trees - my-stuff/py-logrotate.git/commitdiff
Verhalten bei --usage verändert
authorFrank Brehm <frank@brehm-online.com>
Mon, 18 Apr 2011 07:39:51 +0000 (07:39 +0000)
committerFrank Brehm <frank@brehm-online.com>
Mon, 18 Apr 2011 07:39:51 +0000 (07:39 +0000)
git-svn-id: http://svn.brehm-online.com/svn/my-stuff/python/PyLogrotate/trunk@202 ec8d2aa5-1599-4edb-8739-2b3a1bc399aa

LogRotateGetopts.py

index 930504c0c3b9e49775379b257aa35485787b2f10..95dfc06199abe3b91f2c32a780e42d0fdc83a5c1 100755 (executable)
@@ -83,11 +83,14 @@ class LogrotateOptParser(object):
         @type: str
         '''
 
-        self.usage = "Usage: %s [options] <configfile>" %(prog)
+        self.usage = "Usage: %s [options] <configfile>\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.')