Skip to content

Commit

Permalink
fix(cli): allow exclusive arguments as optional
Browse files Browse the repository at this point in the history
The CLI takes its arguments from the RequiredOptional, which has three fields: required, optional, and exclusive. In practice, the exclusive options are not defined as either required or optional, and would not be allowed in the CLI. This changes that, so that exclusive options are also added to the argument parser.

Closes python-gitlab#2769
  • Loading branch information
Sjord authored and JohnVillalovos committed Jan 29, 2024
1 parent 4e68d32 commit bc89c9b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gitlab/v4/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def _populate_sub_parser_by_class(
sub_parser_action.add_argument(
f"--{x.replace('_', '-')}", required=True
)
for x in mgr_cls._create_attrs.optional:
for x in mgr_cls._create_attrs.optional + mgr_cls._create_attrs.exclusive:
sub_parser_action.add_argument(
f"--{x.replace('_', '-')}", required=False
)
Expand All @@ -274,7 +274,7 @@ def _populate_sub_parser_by_class(
f"--{x.replace('_', '-')}", required=True
)

for x in mgr_cls._update_attrs.optional:
for x in mgr_cls._update_attrs.optional + mgr_cls._update_attrs.exclusive:
if x != cls._id_attr:
sub_parser_action.add_argument(
f"--{x.replace('_', '-')}", required=False
Expand Down

0 comments on commit bc89c9b

Please sign in to comment.