def add_cmdline_arg(args, arg, *values):
    """
    Adds a command line argument *arg* to a list of argument *args*, e.g. as returned from
    :py:func:`global_cmdline_args`. When *arg* exists, *args* is returned unchanged. Otherwise,
    *arg* is appended to the end with optional argument *values*. Example:

    .. code-block:: python

        args = global_cmdline_values()
        # -> ["--local-scheduler"]

        add_cmdline_arg(args, "--local-scheduler")
        # -> ["--local-scheduler"]

        add_cmdline_arg(args, "--workers", 4)
        # -> ["--local-scheduler", "--workers", "4"]
    """
    if arg not in args:
        args = list(args) + [arg] + list(values)
    return args