Skip to content

gitea.cli.issue.list

list

List issues command.

Functions:

gitea.cli.issue.list.list_command

list_command(
    ctx: Context,
    owner: Annotated[
        str,
        Option("--owner", help="Owner of the repository."),
    ],
    repository: Annotated[
        str | None,
        Option(
            "--repository", help=REPOSITORY_REQUIRED_HELP
        ),
    ] = None,
    state: Annotated[
        Literal["closed", "open", "all"] | None,
        Option("--state", help="Filter issues by state."),
    ] = None,
    labels: Annotated[
        list[str] | None,
        Option("--labels", help="Filter issues by labels."),
    ] = None,
    search_string: Annotated[
        str | None,
        Option(
            "--search-string",
            help="Filter issues by search string.",
        ),
    ] = None,
    issue_type: Annotated[
        Literal["issues", "pulls"] | None,
        Option(
            "--issue-type", help="Filter by issue type."
        ),
    ] = None,
    milestones: Annotated[
        list[str] | None,
        Option(
            "--milestones",
            help="Filter issues by milestones.",
        ),
    ] = None,
    since: Annotated[
        datetime | None,
        Option(
            "--since",
            help="Filter issues updated since this time.",
        ),
    ] = None,
    before: Annotated[
        datetime | None,
        Option(
            "--before",
            help="Filter issues updated before this time.",
        ),
    ] = None,
    created_by: Annotated[
        str | None,
        Option(
            "--created-by",
            help="Filter issues created by this user.",
        ),
    ] = None,
    assigned_by: Annotated[
        str | None,
        Option(
            "--assigned-by",
            help="Filter issues assigned to this user.",
        ),
    ] = None,
    mentioned_by: Annotated[
        str | None,
        Option(
            "--mentioned-by",
            help="Filter issues mentioning this user.",
        ),
    ] = None,
    page: Annotated[
        int | None,
        Option(
            "--page", help="The page number for pagination."
        ),
    ] = None,
    limit: Annotated[
        int | None,
        Option(
            "--limit", help="The number of issues per page."
        ),
    ] = None,
    account_name: Annotated[
        str | None,
        Option(
            "--account-name",
            help="Name of the account to use for authentication.",
        ),
    ] = None,
    token: Annotated[
        str | None,
        Option(
            "--token",
            help="Token for authentication. If not provided, the token from the specified account will be used.",
        ),
    ] = None,
    base_url: Annotated[
        str | None,
        Option(
            "--base-url",
            help="Base URL of the Gitea platform. If not provided, the base URL from the specified account will be used.",
        ),
    ] = None,
) -> None

List issues in a repository.

Parameters:

Name Type Description Default
ctx Context

The Typer context.

required
owner Annotated[str, Option('--owner', help='Owner of the repository.')]

The owner of the repository.

required
repository Annotated[str | None, Option('--repository', help=REPOSITORY_REQUIRED_HELP)]

The name of the repository, which this command requires.

None
state Annotated[Literal['closed', 'open', 'all'] | None, Option('--state', help='Filter issues by state.')]

Filter issues by state.

None
labels Annotated[list[str] | None, Option('--labels', help='Filter issues by labels.')]

Filter issues by labels.

None
search_string Annotated[str | None, Option('--search-string', help='Filter issues by search string.')]

Filter issues by search string.

None
issue_type Annotated[Literal['issues', 'pulls'] | None, Option('--issue-type', help='Filter by issue type.')]

Filter by issue type.

None
milestones Annotated[list[str] | None, Option('--milestones', help='Filter issues by milestones.')]

Filter issues by milestones.

None
since Annotated[datetime | None, Option('--since', help='Filter issues updated since this time.')]

Filter issues updated since this time.

None
before Annotated[datetime | None, Option('--before', help='Filter issues updated before this time.')]

Filter issues updated before this time.

None
created_by Annotated[str | None, Option('--created-by', help='Filter issues created by this user.')]

Filter issues created by this user.

None
assigned_by Annotated[str | None, Option('--assigned-by', help='Filter issues assigned to this user.')]

Filter issues assigned to this user.

None
mentioned_by Annotated[str | None, Option('--mentioned-by', help='Filter issues mentioning this user.')]

Filter issues mentioning this user.

None
page Annotated[int | None, Option('--page', help='The page number for pagination.')]

The page number for pagination.

None
limit Annotated[int | None, Option('--limit', help='The number of issues per page.')]

The number of issues per page.

None
account_name Annotated[str | None, Option('--account-name', help='Name of the account to use for authentication.')]

Name of the account to use for authentication.

None
token Annotated[str | None, Option('--token', help='Token for authentication. If not provided, the token from the specified account will be used.')]

Token for authentication. If not provided, the token from the specified account will be used.

None
base_url Annotated[str | None, Option('--base-url', help='Base URL of the Gitea platform. If not provided, the base URL from the specified account will be used.')]

Base URL of the Gitea platform. If not provided, the base URL from the specified account will be used.

None
Source code in src/gitea/cli/issue/list.py
def list_command(
    ctx: typer.Context,
    owner: Annotated[str, typer.Option("--owner", help="Owner of the repository.")],
    repository: Annotated[str | None, typer.Option("--repository", help=REPOSITORY_REQUIRED_HELP)] = None,
    state: Annotated[
        Literal["closed", "open", "all"] | None, typer.Option("--state", help="Filter issues by state.")
    ] = None,
    labels: Annotated[
        list[str] | None,
        typer.Option("--labels", help="Filter issues by labels."),
    ] = None,
    search_string: Annotated[
        str | None,
        typer.Option("--search-string", help="Filter issues by search string."),
    ] = None,
    issue_type: Annotated[
        Literal["issues", "pulls"] | None,
        typer.Option("--issue-type", help="Filter by issue type."),
    ] = None,
    milestones: Annotated[
        list[str] | None,
        typer.Option("--milestones", help="Filter issues by milestones."),
    ] = None,
    since: Annotated[
        datetime | None,
        typer.Option("--since", help="Filter issues updated since this time."),
    ] = None,
    before: Annotated[
        datetime | None,
        typer.Option("--before", help="Filter issues updated before this time."),
    ] = None,
    created_by: Annotated[
        str | None,
        typer.Option("--created-by", help="Filter issues created by this user."),
    ] = None,
    assigned_by: Annotated[
        str | None,
        typer.Option("--assigned-by", help="Filter issues assigned to this user."),
    ] = None,
    mentioned_by: Annotated[
        str | None,
        typer.Option("--mentioned-by", help="Filter issues mentioning this user."),
    ] = None,
    page: Annotated[
        int | None,
        typer.Option("--page", help="The page number for pagination."),
    ] = None,
    limit: Annotated[
        int | None,
        typer.Option("--limit", help="The number of issues per page."),
    ] = None,
    account_name: Annotated[
        str | None,
        typer.Option(
            "--account-name",
            help="Name of the account to use for authentication.",
        ),
    ] = None,
    token: Annotated[
        str | None,
        typer.Option(
            "--token",
            help="Token for authentication. If not provided, the token from the specified account will be used.",
        ),
    ] = None,
    base_url: Annotated[
        str | None,
        typer.Option(
            "--base-url",
            help="Base URL of the Gitea platform. If not provided, the base URL from the specified account will be used.",
        ),
    ] = None,
) -> None:
    """List issues in a repository.

    Args:
        ctx: The Typer context.
        owner: The owner of the repository.
        repository: The name of the repository, which this command requires.
        state: Filter issues by state.
        labels: Filter issues by labels.
        search_string: Filter issues by search string.
        issue_type: Filter by issue type.
        milestones: Filter issues by milestones.
        since: Filter issues updated since this time.
        before: Filter issues updated before this time.
        created_by: Filter issues created by this user.
        assigned_by: Filter issues assigned to this user.
        mentioned_by: Filter issues mentioning this user.
        page: The page number for pagination.
        limit: The number of issues per page.
        account_name: Name of the account to use for authentication.
        token: Token for authentication. If not provided, the token from the specified account will be used.
        base_url: Base URL of the Gitea platform. If not provided, the base URL from the specified account will be used.

    """
    from typing import Any  # noqa: PLC0415

    from gitea.cli.utils.api import execute_api_command  # noqa: PLC0415
    from gitea.cli.utils.auth import get_auth_params  # noqa: PLC0415
    from gitea.cli.utils.convert import list_str_to_list_int_or_none  # noqa: PLC0415
    from gitea.cli.utils.options import require_repository  # noqa: PLC0415
    from gitea.client.gitea import Gitea  # noqa: PLC0415

    token, base_url = get_auth_params(
        config_path=ctx.obj.get("config_path"),
        account_name=account_name,
        token=token,
        base_url=base_url,
    )

    milestones_values = list_str_to_list_int_or_none(milestones)

    def api_call() -> tuple[dict[str, Any] | list[dict[str, Any]], dict[str, Any]]:
        """List issues in a repository.

        Returns:
            The issue information as a dictionary.

        """
        target_repository = require_repository(repository, command="gitea-cli issue list")

        with Gitea(token=token, base_url=base_url) as client:
            return client.issue.list_issues(
                owner=owner,
                repository=target_repository,
                state=state,
                labels=labels,
                search_string=search_string,
                issue_type=issue_type,
                milestones=milestones_values,
                since=since,
                before=before,
                created_by=created_by,
                assigned_by=assigned_by,
                mentioned_by=mentioned_by,
                page=page,
                limit=limit,
            )

    execute_api_command(api_call=api_call, base_url=base_url, command_name="gitea-cli issue list")