Register a new command with the tool. 'cmd' is expected to be an instance
        of `Command`, although here only the `cmd.name` attribute is
        investigated. Multiple commands with the same name are not allowed to
        be registered. Returns 'self'.

def register (self, cmd):
        """Register a new command with the tool. 'cmd' is expected to be an instance
        of `Command`, although here only the `cmd.name` attribute is
        investigated. Multiple commands with the same name are not allowed to
        be registered. Returns 'self'.

        """
        if cmd.name is None:
            raise ValueError ('no name set for Command object %r' % cmd)
        if cmd.name in self.commands:
            raise ValueError ('a command named "%s" has already been '
                              'registered' % cmd.name)

        self.commands[cmd.name] = cmd
        return self