def _list(
    env,
    key,
    more,
    loader,
    _all=False,
    output=None,
    flat=False,
    _json=False,
):
    """
    Lists user defined settings or all (including internal configs).

    By default, shows only user defined. If `--all` is passed it also shows
    dynaconf internal variables aswell.
    """
    if env:
        env = env.strip()
    if key:
        key = key.strip()
    if loader:
        loader = loader.strip()

    if env:
        settings.setenv(env)

    cur_env = settings.current_env.lower()

    if cur_env == "main":
        flat = True

    if not _json:
        click.echo(
            click.style(
                f"Working in {cur_env} environment ",
                bold=True,
                bg="bright_blue",
                fg="bright_white",
            )
        )

    if not loader:
        data = settings.as_dict(env=env, internal=_all)
    else:
        identifier = f"{loader}_{cur_env}"
        data = settings._loaded_by_loaders.get(identifier, {})
        data = data or settings._loaded_by_loaders.get(loader, {})

    # remove to avoid displaying twice
    data.pop("SETTINGS_MODULE", None)

    def color(_k):
        if _k in dir(default_settings):
            return "blue"
        return "magenta"

    def format_setting(_k, _v):
        key = click.style(_k, bg=color(_k), fg="bright_white")
        data_type = click.style(
            f"<{type(_v).__name__}>", bg="bright_black", fg="bright_white"
        )
        value = pprint.pformat(_v)
        return f"{key}{data_type} {value}"

    if not key:
        if not _json:
            datalines = "\n".join(
                format_setting(k, v)
                for k, v in data.items()
                if k not in data.get("RENAMED_VARS", [])
            )
            (click.echo_via_pager if more else click.echo)(datalines)
        if output:
            loaders.write(output, prepare_json(data), env=not flat and cur_env)
        if _json:
            json_data = json.dumps(
                prepare_json(data), sort_keys=True, default=repr
            )
            click.echo(json_data, nl=False)
    else:
        key = upperfy(key)

        try:
            value = settings.get(key, empty)
        except AttributeError:
            value = empty

        if value is empty:
            click.secho("Key not found", bg="red", fg="white", err=True)
            sys.exit(1)

        if not _json:
            click.echo(format_setting(key, value))
        if output:
            loaders.write(
                output, prepare_json({key: value}), env=not flat and cur_env
            )
        if _json:
            click.echo(
                json.dumps(prepare_json({key: value}), default=repr), nl=True
            )

    if env:
        settings.setenv()

    Lists user defined settings or all (including internal configs).

    By default, shows only user defined. If `--all` is passed it also shows
    dynaconf internal variables aswell.
    
dynaconf/cli.py