def store_and_consume_remaining(
        option: optparse.Option, opt: str, value: str, parser: optparse.OptionParser
    ):
        """
        A callback for optparse that stores the value and consumes all
        remaining arguments, storing them in the same variable as a tuple.
        """

        # assert a few things we know to be true about the parser
        assert option.dest
        assert parser.rargs is not None
        assert parser.largs is not None

        # everything after this argument should be consumed
        remaining_arguments = parser.rargs + parser.largs
        parser.rargs[:] = []
        parser.largs[:] = []

        setattr(parser.values, option.dest, ValueWithRemainingArgs(value, remaining_arguments))

        A callback for optparse that stores the value and consumes all
        remaining arguments, storing them in the same variable as a tuple.
        
pyinstrument/__main__.py