Skip to content

Exclusive arguments not allowed in CLI #2769

@Sjord

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions