def make_parser_with_config_adder(parser, config):
def internal(arg, **kwargs):<EOL><INDENT>invert = {<EOL>'<STR_LIT:store_true>':'<STR_LIT>',<EOL>'<STR_LIT>':'<STR_LIT:store_true>',<EOL>}<EOL>if arg.startswith('<STR_LIT>'):<EOL><INDENT>key = arg[<NUM_LIT:5>:]<EOL><DEDENT>else:<EOL><INDENT>key = arg[<NUM_LIT:2>:]<EOL><DEDENT>if '<STR_LIT:default>' in kwargs:<EOL><INDENT>if key in config:<EOL><INDENT>kwargs['<STR_LIT:default>'] = config[key]<EOL>del config[key]<EOL><DEDENT><DEDENT>action = kwargs.get('<STR_LIT:action>')<EOL>if action in invert:<EOL><INDENT>exclusive_grp = parser.add_mutually_exclusive_group()<EOL>exclusive_grp.add_argument(arg, **kwargs)<EOL>kwargs['<STR_LIT:action>'] = invert[action]<EOL>kwargs['<STR_LIT>'] = '<STR_LIT>' % arg<EOL>if arg.startswith('<STR_LIT>'):<EOL><INDENT>arg = '<STR_LIT>' % arg[<NUM_LIT:5>:]<EOL><DEDENT>else:<EOL><INDENT>arg = '<STR_LIT>' % arg[<NUM_LIT:2>:]<EOL><DEDENT>exclusive_grp.add_argument(arg, **kwargs)<EOL><DEDENT>else:<EOL><INDENT>parser.add_argument(arg, **kwargs)<EOL><DEDENT><DEDENT>return internal<EOL>
factory function for a smarter parser:

    return an utility function that pull default from the config as well.

    Pull the default for parser not only from the ``default`` kwarg,
    but also if an identical value is find in ``config`` where leading
    ``--`` or ``--no`` is removed.

    If the option is a boolean flag, automatically register an opposite,
    exclusive option by prepending or removing the `--no-`. This is useful
    to overwrite config in ``.travis.yml``

    Mutate the config object and remove know keys in order to detect unused
    options afterwoard.