def main(name, desc, config={}):
  program['name'] = name
  program['desc'] = desc
  
  if len(sys.argv) < 2:
    command, args = '', []
  else:
    command, args = sys.argv[1], sys.argv[2:]
  
  options = config
  for i, arg in enumerate(args):
    if arg.startswith('--'):
      opt = arg.lstrip('--')
      try:
        key, val = opt.split('=')
      except __HOLE__:
        key = opt.split('=')
        val = True
      options[key] = val
      del args[i]

  if command in handlers:
    handler = handlers[command]
  else:
    handler = help

  try:
    handler(*args, **options)
  except Exception as e:
    print "error: %s" % str(e)
dataset/ETHPy150Open adeel/timed/timed/cmdapp.py/main