Ejemplo n.º 1
0
def domain(command, *domain, **opts):
	force = opts['FORCE']
	cmd = CMD.get(command)
	idtype = get_idtype(opts)
	if cmd == CMD_ADD:
		if len(domain) < 1:
			raise Error (ENOARG, 'domain')
		d = Domain_ctl(opts['DB_URI'], any_rpc(opts))
		d.add(domain[0], domain[1:], idtype, force)
	elif cmd == CMD_RM:
		d = Domain_ctl(opts['DB_URI'], any_rpc(opts))
		d.rm(domain, force)
	elif cmd == CMD_SHOW:
		if not domain:
			domain = None
		else:
			domain = domain[0]
		cols, fformat, limit, rsep, lsep, astab = show_opts(opts)
		u = Domain(opts['DB_URI'])
		if opts['DID']:
			uri_list, desc = u.show_did(domain, cols=cols, fformat=fformat, limit=limit)
		elif opts['DEPTH']:
			uri_list, desc = u.show_did_for_domain(domain, cols=cols, fformat=fformat, limit=limit)
		else:
			uri_list, desc = u.show_domain(domain, cols=cols, fformat=fformat, limit=limit)
		tabprint(uri_list, desc, rsep, lsep, astab)
	else:
		raise Error (EINVAL, command)