def parse_unknown_args(**unk_args):
    """Parse kwargs like `dict(foo=False, bar=42)` into parameters like
    `--no-foo --bar 42`."""
    parsed = []
    for key, value in unk_args.items():
        base_name = key.replace('_', '-')
        if isinstance(value, bool):
            # boolean values don't follow the normal "--key value" format; have
            # to handle them like "--key" or "--no-key" instead.
            if value:
                parsed.append('--' + base_name)
            else:
                parsed.append('--no-' + base_name)
        else:
            # otherwise we assume normal "--key value" format.
            parsed.extend(['--' + base_name, str(value)])
    return parsed