Skip to content

Exclusive arguments not allowed in CLI #2769

Closed

Description

@Sjord

In gitlab/v4/cli.py, required and optional arguments are added to the argument parser:

if action_name == "create":
    for x in mgr_cls._create_attrs.required:
        sub_parser_action.add_argument(
            f"--{x.replace('_', '-')}", required=True
        )
    for x in mgr_cls._create_attrs.optional:
        sub_parser_action.add_argument(
            f"--{x.replace('_', '-')}", required=False
        )

Besides required and optional, the RequiredOptional class can also have an exclusive field, and many objects use this to list options not in required or optional. From gitlab/v4/objects/invitations.py:

class ProjectInvitationManager(InvitationMixin, RESTManager):
    _path = "/projects/{project_id}/invitations"
    _obj_cls = ProjectInvitation
    _from_parent_attrs = {"project_id": "id"}
    _create_attrs = RequiredOptional(
        required=("access_level",),
        optional=(
            "expires_at",
            "invite_source",
            "tasks_to_be_done",
            "tasks_project_id",
        ),
        exclusive=("email", "user_id"),
    )

Here email is an argument defined in exclusive, and not allowed on the CLI:

$ python -m gitlab --server-url http://172.16.38.146/ project-invitation create --access-level 10 --email myemail --project-id 1
...
__main__.py: error: unrecognized arguments: --email myemail

Issue #2738 describes a similar problem.

Activity

  1. added 2 commits that reference this issue on Jan 21, 2024
    8638972
    9a16bdd
  2. added 2 commits that reference this issue on Jan 28, 2024
    d9d260c
    bc89c9b
  3. added a commit that references this issue on Jan 29, 2024
    7ec3189
  4. locked as resolved and limited conversation to collaborators on Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions