def run(self, instream=sys.stdin):
        """Runs the CLI, reading from sys.stdin by default
        """
        sys.stdout.write(self.prompt)
        sys.stdout.flush()
        while True:
            line = instream.readline()
            try:
                self.exec_cmd(line)
            except Exception as e:
                self.errfun(e)

            sys.stdout.write(self.prompt)
            sys.stdout.flush()