summaryrefslogtreecommitdiff
path: root/freebase/fcl/fcl.py
diff options
context:
space:
mode:
authoralecflett <alecflett@5914aa95-5b3a-0410-a3b5-7b719e7fe9b2>2009-09-21 20:51:30 +0000
committeralecflett <alecflett@5914aa95-5b3a-0410-a3b5-7b719e7fe9b2>2009-09-21 20:51:30 +0000
commitb6b6dbfb28fc158a559d0cef669ac6cda9d97be7 (patch)
tree8eb666b7187bd61e6acc7e61d587ca645079ee3c /freebase/fcl/fcl.py
parent821f14dbdb3d8ff8cb6cd8dd78bb9b8c74836bf1 (diff)
fix when required arguments are not specified - at least spit a semi-sane message to the user rather than totally barfing
git-svn-id: http://freebase-python.googlecode.com/svn/trunk@215 5914aa95-5b3a-0410-a3b5-7b719e7fe9b2
Diffstat (limited to 'freebase/fcl/fcl.py')
-rwxr-xr-xfreebase/fcl/fcl.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/freebase/fcl/fcl.py b/freebase/fcl/fcl.py
index 2b30b56..812b7fe 100755
--- a/freebase/fcl/fcl.py
+++ b/freebase/fcl/fcl.py
@@ -33,7 +33,12 @@ from optparse import OptionParser
import getpass
import cookielib
import logging
-import simplejson
+import inspect
+
+try:
+ import simplejson as json
+except ImportError:
+ import json
from cmdutil import CmdException, log, out
@@ -182,6 +187,13 @@ class FclCommandHandler(object):
def dispatch(self, cmd, args, kws):
try:
+ spec = inspect.getargspec(cmd.func)
+ required = len(spec.args) - len(spec.defaults or ())
+ if len(args) < (required-1):
+ sys.stderr.write("%s: arguments \"%s\" required\n" %
+ (cmd.func.__name__,
+ '\", \"'.join(spec.args[1:required])))
+ sys.exit(1)
cmd.func(self, *args, **kws)
# flush the output