What is the rationale behind the code in cmdloop() which calls sys.exit(self.exit_code) if the exit_code attribute is set?
I have lots of questions about the implementation, but I'll save them until I understand what we were trying to solve with this code.