From b77c39181c8cdd73682483e1e3bda1a7dfddf09d Mon Sep 17 00:00:00 2001 From: "John L. Villalovos" Date: Sat, 6 Mar 2021 21:45:39 -0800 Subject: [PATCH] WIP: Proof-of-concept for _arg_name for argument names --- gitlab/base.py | 2 ++ gitlab/v4/cli.py | 5 ++++- gitlab/v4/objects/ldap.py | 1 + gitlab/v4/objects/users.py | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/gitlab/base.py b/gitlab/base.py index ed551ff65..f0a0d4072 100644 --- a/gitlab/base.py +++ b/gitlab/base.py @@ -39,6 +39,8 @@ class RESTObject(object): without ID in the url. """ + # If _arg_name is set, used by the CLI to determine the argument name + _arg_name: Optional[str] = None _id_attr: Optional[str] = "id" _attrs: Dict[str, Any] _module: ModuleType diff --git a/gitlab/v4/cli.py b/gitlab/v4/cli.py index 6172f9310..5193afdf7 100644 --- a/gitlab/v4/cli.py +++ b/gitlab/v4/cli.py @@ -301,7 +301,10 @@ def extend_parser(parser): classes.sort(key=operator.attrgetter("__name__")) for cls in classes: - arg_name = cli.cls_to_what(cls) + if cls._arg_name is not None: + arg_name = cls._arg_name + else: + arg_name = cli.cls_to_what(cls) object_group = subparsers.add_parser(arg_name) object_subparsers = object_group.add_subparsers( diff --git a/gitlab/v4/objects/ldap.py b/gitlab/v4/objects/ldap.py index 72c8e7f39..edf373e4b 100644 --- a/gitlab/v4/objects/ldap.py +++ b/gitlab/v4/objects/ldap.py @@ -9,6 +9,7 @@ class LDAPGroup(RESTObject): + _arg_name = "ldap-group" _id_attr = None diff --git a/gitlab/v4/objects/users.py b/gitlab/v4/objects/users.py index 4f14e86b3..f07ab5669 100644 --- a/gitlab/v4/objects/users.py +++ b/gitlab/v4/objects/users.py @@ -64,6 +64,7 @@ class CurrentUserEmailManager(RetrieveMixin, CreateMixin, DeleteMixin, RESTManag class CurrentUserGPGKey(ObjectDeleteMixin, RESTObject): + _arg_name = "current-user-gpg-key" pass @@ -364,6 +365,7 @@ class UserActivitiesManager(ListMixin, RESTManager): class UserGPGKey(ObjectDeleteMixin, RESTObject): + _arg_name = "user-gpg-key" pass