import click
import functools


def common_args(func):
    """
    Decorator to contain CLI args that will be common to both CLI and GUI: title and engine args.
    """
    @click.option("--title", "-t", help="Title to display (if omitted will use file name).")
    @click.option(
        "--layout",
        "-l",
        default=[],
        multiple=True,
        show_default=True,
        help="Layout name, eg, 'umap'."
    )
    @click.option("--obs-names", default=None, metavar="", help="Name of annotation field to use for observations.")
    @click.option("--var-names", default=None, metavar="", help="Name of annotation to use for variables.")
    @click.option(
        "--max-category-items",
        default=1000,
        metavar="",
        show_default=True,
        help="Categories with more distinct values than this will not be displayed.",
    )
    @click.option(
        "--diffexp-lfc-cutoff",
        default=0.01,
        show_default=True,
        help="Relative expression cutoff used when selecting top N differentially expressed genes",
    )
    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        return func(*args, **kwargs)
    return wrapper