From: Brian Dolbec Date: Fri, 27 Jan 2012 09:52:33 +0000 (-0800) Subject: Fix bug 400957 where -hC did not work to to printing help immediately upon finding... X-Git-Tag: gentoolkit-0.3.0.5~4^2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=10327ce9c7cd0f61c972a48d3c8b2efe470582ef;p=gentoolkit.git Fix bug 400957 where -hC did not work to to printing help immediately upon finding the -h option and not parsing the remaining options. Fixed equery, enalyze, eclean, revdep-rebuild (although, python revdep did not colorize the help). --- diff --git a/pym/gentoolkit/base.py b/pym/gentoolkit/base.py index 3d662d5..7803d2d 100644 --- a/pym/gentoolkit/base.py +++ b/pym/gentoolkit/base.py @@ -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 diff --git a/pym/gentoolkit/eclean/cli.py b/pym/gentoolkit/eclean/cli.py index 8d47cfb..a56f1ab 100644 --- a/pym/gentoolkit/eclean/cli.py +++ b/pym/gentoolkit/eclean/cli.py @@ -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) diff --git a/pym/gentoolkit/equery/__init__.py b/pym/gentoolkit/equery/__init__.py index e79e04f..9e8834b 100644 --- a/pym/gentoolkit/equery/__init__.py +++ b/pym/gentoolkit/equery/__init__.py @@ -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 diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py index fe00069..6bcc972 100644 --- a/pym/gentoolkit/revdep_rebuild/rebuild.py +++ b/pym/gentoolkit/revdep_rebuild/rebuild.py @@ -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