Fix bug 400957 where -hC did not work to to printing help immediately upon finding...
authorBrian Dolbec <dolsen@gentoo.org>
Fri, 27 Jan 2012 09:52:33 +0000 (01:52 -0800)
committerBrian Dolbec <dolsen@gentoo.org>
Fri, 27 Jan 2012 09:52:33 +0000 (01:52 -0800)
pym/gentoolkit/base.py
pym/gentoolkit/eclean/cli.py
pym/gentoolkit/equery/__init__.py
pym/gentoolkit/revdep_rebuild/rebuild.py

index 3d662d5d5b6de364e686f94beb01ffa2b0ba2102..7803d2d6f9b877879127e6ad279f5f4c3a045a10 100644 (file)
@@ -108,14 +108,15 @@ def parse_global_options(global_opts, args, module_info, formatted_options):
        """
 
        need_help = False
+       do_help = False
        opts = (opt[0] for opt in global_opts)
        for opt in opts:
                if opt in ('-h', '--help'):
+                       do_help = True
                        if args:
                                need_help = True
                        else:
-                               print_help( module_info, formatted_options)
-                               sys.exit(0)
+                               do_help = True
                elif opt in ('-q','--quiet'):
                        gentoolkit.CONFIG['quiet'] = True
                elif opt in ('-C', '--no-color', '--nocolor'):
@@ -128,6 +129,9 @@ def parse_global_options(global_opts, args, module_info, formatted_options):
                        sys.exit(0)
                elif opt in ('--debug'):
                        gentoolkit.CONFIG['debug'] = True
+       if do_help:
+               print_help( module_info, formatted_options)
+               sys.exit(0)
        return need_help
 
 
index 8d47cfb7032a45cd2c0989cd902ef0524ac45432..a56f1ab0fde9c5a5430ea40cdc18c697c0c608e2 100644 (file)
@@ -228,12 +228,10 @@ def parseArgs(options={}):
                """local function for interpreting command line options
                and setting options accordingly"""
                return_code = True
+               do_help = False
                for o, a in opts:
                        if o in ("-h", "--help"):
-                               if action:
-                                       raise ParseArgsException('help-'+action)
-                               else:
-                                       raise ParseArgsException('help')
+                               do_help = True
                        elif o in ("-V", "--version"):
                                raise ParseArgsException('version')
                        elif o in ("-C", "--nocolor"):
@@ -273,6 +271,11 @@ def parseArgs(options={}):
                                        print( pp.error(
                                                "--%s only makes sense in --destructive mode." % opt), file=sys.stderr)
                                options[opt] = False
+               if do_help:
+                       if action:
+                               raise ParseArgsException('help-'+action)
+                       else:
+                               raise ParseArgsException('help')
                return return_code
 
        # here are the different allowed command line options (getopt args)
index e79e04ff9becd0d45de7689bed398a44c0761010..9e8834be74e936f708881298113ef0342b67e149 100644 (file)
@@ -263,14 +263,14 @@ def parse_global_options(global_opts, args):
        """
 
        need_help = False
+       do_help = False
        opts = (opt[0] for opt in global_opts)
        for opt in opts:
                if opt in ('-h', '--help'):
                        if args:
                                need_help = True
                        else:
-                               print_help()
-                               sys.exit(0)
+                               do_help = True
                elif opt in ('-q','--quiet'):
                        CONFIG['quiet'] = True
                elif opt in ('-C', '--no-color', '--nocolor'):
@@ -283,7 +283,9 @@ def parse_global_options(global_opts, args):
                        sys.exit(0)
                elif opt in ('--debug'):
                        CONFIG['debug'] = True
-
+       if do_help:
+               print_help()
+               sys.exit(0)
        return need_help
 
 
index fe00069953c6223e99c8c09e5e477b664f26acbd..6bcc9727a4daae6263adf7d13f45e6cc42d285ca 100644 (file)
@@ -103,10 +103,10 @@ def parse_options():
                        'keep-temp', 'library=', 'no-ld-path', 'no-order',
                        'pretend', 'no-pretend', 'no-progress', 'quiet', 'verbose'])
 
+               do_help = False
                for key, val in opts:
                        if key in ('-h', '--help'):
-                               print_usage()
-                               sys.exit(0)
+                               do_help = True
                        elif key in ('-q', '--quiet'):
                                settings['quiet'] = True
                                settings['VERBOSITY'] = 0
@@ -134,6 +134,9 @@ def parse_options():
                print(red('Unrecognized option\n'))
                print_usage()
                sys.exit(2)
+       if do_help:
+               print_usage()
+               sys.exit(0)
        return settings