diff options
| -rwxr-xr-x | gitlab | 21 | ||||
| -rw-r--r-- | gitlab.py | 6 |
2 files changed, 18 insertions, 9 deletions
@@ -59,8 +59,9 @@ def actionHelpList(cls): detail += " " detail += "--page=ARG --per-page=ARG" elif action in ['get', 'delete']: - detail = "--id=ARG " - detail += " ".join(["--%s=ARG" % x.replace('_', '-') for x in cls.requiredGetAttrs]) + if cls not in [gitlab.CurrentUser]: + detail = "--id=ARG " + detail += " ".join(["--%s=ARG" % x.replace('_', '-') for x in cls.requiredGetAttrs]) elif action == 'create': detail = " ".join(["--%s=ARG" % x.replace('_', '-') for x in cls.requiredCreateAttrs]) if detail: @@ -113,7 +114,7 @@ args = [] d = {} for arg in sys.argv[1:]: if arg.startswith('--'): - arg = arg[2:].replace('-', '_') + arg = arg[2:] if arg == 'help': usage() @@ -122,8 +123,8 @@ for arg in sys.argv[1:]: verbose = True continue - k, v = arg.split('=', 2) - k = k.strip() + k, v = arg.split('=', 1) + k = k.strip().replace('_', '-') v = v.strip() if k == 'gitlab': @@ -219,10 +220,12 @@ elif action == "get": if not cls.canGet: die("%s objects can't be retrieved" % what) - try: - id = d.pop('id') - except: - die("Missing --id argument") + id = None + if cls not in [gitlab.CurrentUser]: + try: + id = d.pop('id') + except: + die("Missing --id argument") try: o = cls(gl, id, **d) @@ -278,6 +278,9 @@ class Gitlab(object): url = obj._url % obj.__dict__ url = '%s%s?private_token=%s' % (self._url, url, self.private_token) + print url + print obj.__dict__ + try: # TODO: avoid too much work on the server side by filtering the # __dict__ keys @@ -529,6 +532,8 @@ class User(GitlabObject): class CurrentUserKey(GitlabObject): _url = '/user/keys' canUpdate = False + shortPrintAttr = 'title' + requiredCreateAttrs = ['title', 'key'] class CurrentUser(GitlabObject): @@ -537,6 +542,7 @@ class CurrentUser(GitlabObject): canCreate = False canUpdate = False canDelete = False + shortPrintAttr = 'username' def Key(self, id=None, **kwargs): if id is None: |
