Repository: PrefectHQ/prefect
File: src/prefect/cli/artifact.py (Python)

Code before:
async def list_artifacts(
    limit: int = typer.Option(
        100,
        "--limit",
        help="The maximum number of artifacts to return.",
    ),
    all: bool = typer.Option(
        False,
        "--all",
        "-a",
        help="Whether or not to only return the latest version of each artifact.",
    ),
    output: Optional[str] = typer.Option(
        None,
        "--output",
        "-o",
        help="Specify an output format. Currently supports: json",
    ),
):
    """
    List artifacts.

    Arguments:
    limit: Maximum number of flow runs to list. Defaults to 100.
    all: Whether or not to only return the latest version of each artifact.
    output: Return variables in specified format.
    """

    if output and output.lower() != "json":
        exit_with_error("Only 'json' output format is supported.")

    async with get_client() as client:
        if all:
            artifacts = await client.read_artifacts(
                sort=ArtifactSort.KEY_ASC,
                limit=limit,
            )
        else:
            artifacts = await client.read_latest_artifacts(
                sort=ArtifactCollectionSort.KEY_ASC,
                limit=limit,
            )

    if output and output.lower() == "json":
        artifacts_json = [artifact.model_dump(mode="json") for artifact in artifacts]
        json_output = orjson.dumps(artifacts_json, option=orjson.OPT_INDENT_2).decode()
        app.console.print(json_output)
    else:
        table = Table(
            title="Artifacts",
            caption="List Artifacts using `prefect artifact ls`",

Review comment (suggestion):
```suggestion
    Arguments:
        limit: Maximum number of flow runs to list. Defaults to 100.
        all: Whether or not to only return the latest version of each artifact.
        output: Return variables in specified format.
```

Code after:
async def list_artifacts(
    limit: int = typer.Option(
        100,
        "--limit",
        help="The maximum number of artifacts to return.",
    ),
    all: bool = typer.Option(
        False,
        "--all",
        "-a",
        help="Whether or not to only return the latest version of each artifact.",
    ),
    output: Optional[str] = typer.Option(
        None,
        "--output",
        "-o",
        help="Specify an output format. Currently supports: json",
    ),
):
    """
    List artifacts.

    Arguments:
        limit: Maximum number of flow runs to list. Defaults to 100.
        all: Whether or not to only return the latest version of each artifact.
        output: Return variables in specified format.
    """

    if output and output.lower() != "json":
        exit_with_error("Only 'json' output format is supported.")

    async with get_client() as client:
        if all:
            artifacts = await client.read_artifacts(
                sort=ArtifactSort.KEY_ASC,
                limit=limit,
            )
        else:
            artifacts = await client.read_latest_artifacts(
                sort=ArtifactCollectionSort.KEY_ASC,
                limit=limit,
            )

    if output and output.lower() == "json":
        artifacts_json = [artifact.model_dump(mode="json") for artifact in artifacts]
        json_output = orjson.dumps(artifacts_json, option=orjson.OPT_INDENT_2).decode()
        app.console.print(json_output)
    else:
        table = Table(
            title="Artifacts",
            caption="List Artifacts using `prefect artifact ls`",