diff options
author | Gauvain Pocentek <gauvain.pocentek@objectif-libre.com> | 2015-07-11 08:56:17 +0200 |
---|---|---|
committer | Gauvain Pocentek <gauvain.pocentek@objectif-libre.com> | 2015-07-11 08:57:44 +0200 |
commit | 802c144cfd199684506b3404f03c3657c75e307d (patch) | |
tree | 1ab2f010b98c368288867ecc9a7bd1d5a5fccf47 /gitlab/cli.py | |
parent | e57b7794d1e1ae6795f5b914132a2891dc0d9509 (diff) | |
download | gitlab-802c144cfd199684506b3404f03c3657c75e307d.tar.gz |
Fix the update/delete CLI subcommands
Also update the testing tool to test these features.
Closes #62
Diffstat (limited to 'gitlab/cli.py')
-rw-r--r-- | gitlab/cli.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/gitlab/cli.py b/gitlab/cli.py index 9c07e82..d678439 100644 --- a/gitlab/cli.py +++ b/gitlab/cli.py @@ -103,12 +103,23 @@ def populate_sub_parser_by_class(cls, sub_parser): for x in cls.optionalCreateAttrs] elif action_name == UPDATE: + id_attr = cls.idAttr.replace('_', '-') + sub_parser_action.add_argument("--%s" % id_attr, + required=True) + + attrs = (cls.requiredUpdateAttrs + if cls.requiredUpdateAttrs is not None + else cls.requiredCreateAttrs) [sub_parser_action.add_argument("--%s" % x.replace('_', '-'), required=True) - for x in cls.requiredCreateAttrs] + for x in attrs] + + attrs = (cls.optionalUpdateAttrs + if cls.optionalUpdateAttrs is not None + else cls.optionalCreateAttrs) [sub_parser_action.add_argument("--%s" % x.replace('_', '-'), required=False) - for x in cls.optionalCreateAttrs] + for x in attrs] if cls in extra_actions: for action_name in sorted(extra_actions[cls]): @@ -182,7 +193,7 @@ def do_delete(cls, gl, what, args): if not cls.canDelete: die("%s objects can't be deleted" % what) - o = do_get(cls, args, what, args) + o = do_get(cls, gl, what, args) try: o.delete() except Exception as e: @@ -193,7 +204,7 @@ def do_update(cls, gl, what, args): if not cls.canUpdate: die("%s objects can't be updated" % what) - o = do_get(cls, args, what, args) + o = do_get(cls, gl, what, args) try: for k, v in args.items(): o.__dict__[k] = v |