From: W. Trevor King Date: Thu, 19 Aug 2010 18:36:48 +0000 (-0400) Subject: Log the troublesome command for command line option conflicts. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b2ef9d8c1cf89f05b085bfebe510dccd51ca4ddc;p=hooke.git Log the troublesome command for command line option conflicts. --- diff --git a/hooke/ui/commandline.py b/hooke/ui/commandline.py index e73e22d..01a66f8 100644 --- a/hooke/ui/commandline.py +++ b/hooke/ui/commandline.py @@ -63,15 +63,23 @@ class CommandLineParser (optparse.OptionParser): type = a.type if type == 'bool': if a.default == True: - self.add_option( - '--disable-%s' % name, dest=name, default=Default, - action='store_false') + try: + self.add_option( + '--disable-%s' % name, dest=name, + default=Default, action='store_false') + except optparse.OptionConflictError, e: + logging.warn('error in %s: %s' % (command, e)) + raise self.command_opts.append(a) continue elif a.default == False: - self.add_option( - '--enable-%s' % name, dest=name, default=Default, - action='store_true') + try: + self.add_option( + '--enable-%s' % name, dest=name, + default=Default, action='store_true') + except optparse.OptionConflictError, e: + logging.warn('error in %s: %s' % (command, e)) + raise self.command_opts.append(a) continue else: @@ -79,8 +87,12 @@ class CommandLineParser (optparse.OptionParser): elif type not in ['string', 'int', 'long', 'choice', 'float', 'complex']: type = 'string' - self.add_option( - '--%s' % name, dest=name, type=type, default=Default) + try: + self.add_option( + '--%s' % name, dest=name, type=type, default=Default) + except optparse.OptionConflictError, e: + logging.warn('error in %s: %s' % (command, e)) + raise self.command_opts.append(a) else: self.command_args.append(a)