def merge_contexts(ctx, obj):
    """Return the given context with the attributes of another object
    merged into it. This is useful to attach a separate application
    context to a Click context.
    """
    for attr in obj.__dir__():
        if not attr.startswith("__"):
            ctx.__setattr__(attr, getattr(obj, attr))
    return ctx