def docopt_cmd(func):
 def fn(self, arg):
  try:
   opt = docopt(fn.__doc__, arg)
  except DocoptExit as e:
   print 'Invalid Command!'
   print e
   return
  except SystemExit:
   return
  return func(self, opt)
 fn.__name__ = func.__name__
 fn.__doc__ = func.__doc__
 fn.__dict__.update(func.__dict__)
 return fn

def docopt_cmd ( func ) : def fn ( self , arg ) : try : opt = docopt ( fn . __doc__ , arg ) except DocoptExit as e : print 'Invalid Command!' print e return except SystemExit : return return func ( self , opt ) fn . __name__ = func . __name__ fn . __doc__ = func . __doc__ fn . __dict__ . update ( func . __dict__ ) return fn
this decorator is used to simplify the try/except block and pass the result of the docopt parsing to the called action .