Check if short name is of length == 1
authorAlexander Solovyov <piranha@piranha.org.ua>
Fri, 07 Aug 2009 16:47:17 +0300
changeset 71 78fa11005c83
parent 70 74b690e79606
child 72 b5bf4c1f3a68
Check if short name is of length == 1
finaloption.py
--- a/finaloption.py	Tue Aug 04 20:30:02 2009 +0300
+++ b/finaloption.py	Fri Aug 07 16:47:17 2009 +0300
@@ -264,6 +264,9 @@
     shortlist, namelist = '', []
 
     for short, name, default, comment in options:
+        if short and len(short) != 1:
+            raise FOError('Short option should be only a single'
+                          ' character: %s' % short)
         # change name to match Python styling
         pyname = name.replace('-', '_')
         argmap['-' + short] = argmap['--' + name] = pyname
@@ -427,6 +430,8 @@
     except getopt.GetoptError, e:
         err('error: %s\n' % e)
         help_func()
+    except FOError, e:
+        err('%s\n' % e)
     except KeyboardInterrupt:
         err('interrupted!\n')
     except SystemExit:
@@ -488,3 +493,6 @@
 
 class Abort(CommandException):
     'Abort execution'
+
+class FOError(CommandException):
+    'Raised on trouble with finaloption configuration'