def set_cli_options(config, arguments=None):
    """Set any configuration options which have a CLI value set.

    Args:
        config (confpy.core.config.Configuration): A configuration object which
            has been initialized with options.
        arguments (iter of str): An iterable of strings which contains the CLI
            arguments passed. If nothing is give then sys.argv is used.

    Returns:
        confpy.core.config.Configuration: A configuration object with CLI
            values set.

    The pattern to follow when setting CLI values is:

        <section>_<option>

    Each value should be lower case and separated by underscores.
    """
    arguments = arguments or sys.argv[1:]
    parser = argparse.ArgumentParser()
    for section_name, section in config:

        for option_name, _ in section:

            var_name = '{0}_{1}'.format(
                section_name.lower(),
                option_name.lower(),
            )
            parser.add_argument('--{0}'.format(var_name))

    args, _ = parser.parse_known_args(arguments)
    args = vars(args)
    for section_name, section in config:

        for option_name, _ in section:

            var_name = '{0}_{1}'.format(
                section_name.lower(),
                option_name.lower(),
            )
            value = args.get(var_name)
            if value:

                setattr(section, option_name, value)

    return config