def keyval_list_to_dict(arg_list: list) -> dict:
    """
    Helper routine for converting command line argument strings in the form
    ``'key1=val1,key2=val2,...'`` into a dictionary suitable for
    passing to a function as ``**kwargs``.

    If a key is specified in the string with no value, it is assigned a value of ``True``.

    It is the responsibility of the caller or code consuming the diectionary to validate the types
    and values of the dictionary entries.
    """
    arg_dict = {}
    for arg in arg_list:
        keyvals = arg.split(',')
        for keyval in keyvals:
            fields = keyval.split('=')
            if len(fields) in (1, 2):
                key = fields[0].strip()

                if len(fields) == 1:
                    # Just a boolean setting
                    arg_dict[key] = True
                else:
                    # Attempt to interpret integer setting values
                    value = fields[1].strip()
                    try:
                        arg_dict[key] = int(value, 0)
                    except ValueError:
                        arg_dict[key] = value
            else:
                keyval = '<empty>' if len(keyval) == 0 else keyval
                err = 'Invalid argument. Expected key=val syntax: ' + keyval
                raise ValueError(err)

    return arg_dict