def do_add(self, options): """Add new host command. Each host is composed of three parts: * IP name * Main hostname * An alias to the main hostname. Both three arguments are requied. :Results: None """ hosts = Hosts() try: hosts.add(options.ip, options.hostname, options.alias) except IOError as e: if e.errno == 13: print("You don't have permissions to write '%s'. %s" % (hosts.hosts_file, "Did you forgot 'sudo'?")) else: raise IOError exit(1)