Log the troublesome command for command line option conflicts.
authorW. Trevor King <wking@drexel.edu>
Thu, 19 Aug 2010 18:36:48 +0000 (14:36 -0400)
committerW. Trevor King <wking@drexel.edu>
Thu, 19 Aug 2010 18:36:48 +0000 (14:36 -0400)
hooke/ui/commandline.py

index e73e22d68126af9bd04923bf32ec2870f402833d..01a66f8b9d55902647adacffcb7e01e4f07d0e53 100644 (file)
@@ -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)