import click


def fetch_config(ctx):
    """ Fetch `config_file` from context
    """
    config = ctx.obj and ctx.obj.get('config', None)
    if not config:
        _opts = dict((o.name, o) for o in ctx.parent.command.params)
        raise click.BadParameter('Must specify configuration file',
                                 ctx=ctx.parent, param=_opts['config_file'])
    return config