check that option has a name
authorAlexander Solovyov <piranha@piranha.org.ua>
Fri, 07 Aug 2009 16:47:36 +0300
changeset 72 b5bf4c1f3a68
parent 71 78fa11005c83
child 73 d283be877fc5
check that option has a name
finaloption.py
test_cmd.py
--- a/finaloption.py	Fri Aug 07 16:47:17 2009 +0300
+++ b/finaloption.py	Fri Aug 07 16:47:36 2009 +0300
@@ -124,8 +124,7 @@
             lambda: call_cmd(name, middleware(func), *args, **kwargs),
             help_func)
     except Abort:
-        pass
-    return -1
+        return -1
 
 # --------
 # Help
@@ -267,6 +266,9 @@
         if short and len(short) != 1:
             raise FOError('Short option should be only a single'
                           ' character: %s' % short)
+        if not name:
+            raise FOError(
+                'Long name should be defined for every option')
         # change name to match Python styling
         pyname = name.replace('-', '_')
         argmap['-' + short] = argmap['--' + name] = pyname
--- a/test_cmd.py	Fri Aug 07 16:47:17 2009 +0300
+++ b/test_cmd.py	Fri Aug 07 16:47:36 2009 +0300
@@ -16,10 +16,9 @@
     ('p', 'port', 5000, 'The port for the server.'),
     ('', 'nolint', False, 'Do not use LintMiddleware')
 ])
-def runserver(config, host, port, nolint):
+def runserver(**opts):
     """Run development server"""
-
-    pass
+    print opts
 
 
 finaloption.dispatch()