Skip to content

Commit

Permalink
gitlab: update the object syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauvain Pocentek committed May 19, 2013
1 parent e7ba350 commit 9ca47aa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
21 changes: 12 additions & 9 deletions README.md
Expand Up @@ -95,34 +95,37 @@ The first argument is the object type on which we will act, the second one is
the action:

`````
gitlab Project list
gitlab project list
`````

The usable objects are those which inherits GitlabObject (yes, the source is
the doc ATM), and the actions are list, get, create, update, delete.
the doc ATM), with a bit of string transformation (Project => project,
ProjectIssue => project-issue, ...).

The actions are list, get, create, update, delete.

Some examples:

`````bash
# list all the projects:
gitlab Project list
gitlab project list

# get a specific project (id 2):
gitlab Project get --id=2
gitlab project get --id=2

# get a list of snippets for this project:
gitlab ProjectIssue list --project_id=2
gitlab project-issue list --project_id=2

# delete a Snippet (id 3):
gitlab ProjectSnippet delete --id=3 --project_id=2
gitlab project-snippet delete --id=3 --project_id=2

# update a Snippet:
gitlab ProjectSnippet update --id=4 --project_id=2 --code="My New Code"
gitlab project-snippet update --id=4 --project_id=2 --code="My New Code"

# create a Snippet:
gitlab ProjectSnippet create --project_id=2
gitlab project-snippet create --project_id=2
Impossible to create object (Missing attribute(s): title, file_name, code)

# oops, let's add the attributes:
gitlab ProjectSnippet create --project_id=2 --title="the title" --file_name="the name" --code="the code"
gitlab project-snippet create --project_id=2 --title="the title" --file_name="the name" --code="the code"
`````
5 changes: 4 additions & 1 deletion gitlab
Expand Up @@ -81,8 +81,11 @@ except:
if action not in ['get', 'list', 'update', 'create', 'delete']:
die("Unknown action: %s" % action)

def whatToCls(what):
return "".join([s.capitalize() for s in what.split("-")])

try:
cls = gitlab.__dict__[what]
cls = gitlab.__dict__[whatToCls(what)]
except:
die("Unknown object: %s" % what)

Expand Down

0 comments on commit 9ca47aa

Please sign in to comment.