def run(self, commands=None, default_command=None):
        
        """
        Prepares manager to receive command line input. Usually run
        inside "if __name__ == "__main__" block in a Python script.

        :param commands: optional dict of commands. Appended to any commands 
                         added using add_command().

        :param default_command: name of default command to run if no 
                                arguments passed.
        """

        if commands:
            self._commands.update(commands)

        try:
            if len(sys.argv) == 1 and default_command is not None:
                command = default_command
            else:
                command = sys.argv[1]

            if command is None:
                raise InvalidCommand, "Please provide a command"

            self.handle(sys.argv[0],
                        command,
                        sys.argv[2:])
            
            sys.exit(0)

        except __HOLE__:
            self.print_usage()
            sys.exit(0)
        
        except InvalidCommand, e:
            print e
            self.print_usage()

        sys.exit(1)
dataset/ETHPy150Open danjac/Flask-Script/flaskext/script.py/Manager.run