@@ -4,6 +4,8 @@ python-gitlab is a Python module providing access to the GitLab server API.
4
4
5
5
It supports the v3 api of GitLab.
6
6
7
+ A CLI tool is also provided (called ** gitlab** ).
8
+
7
9
## Requirements
8
10
9
11
Only Python 2 is supported for the moment.
@@ -18,7 +20,7 @@ python-gitlab is a work in progress, although already usable. Changes in the API
18
20
19
21
* Improve documentation
20
22
* Write unit tests
21
- * Write a command line tool to access GitLab servers
23
+ * Improve the command line tool
22
24
23
25
## Code snippet
24
26
@@ -55,3 +57,74 @@ p.save()
55
57
print p
56
58
`````
57
59
60
+ ## Command line use
61
+
62
+ To use the command line tool, you need to define which GitLab server(s) can be
63
+ accessed. this can be done in 2 files:
64
+
65
+ * /etc/python-gitlab.cfg
66
+ * ~ /.python-gitlab.cfg
67
+
68
+ Here's an example of the syntax:
69
+
70
+ `````
71
+ [global]
72
+ default = local
73
+
74
+ [local]
75
+ url = http://10.0.3.2:8080
76
+ private_token = vTbFeqJYCY3sibBP7BZM
77
+
78
+ [distant]
79
+ url = https://some.whe.re
80
+ private_token = thisisaprivatetoken
81
+ `````
82
+
83
+ The [ global] section define which server is accesed by default.
84
+ Each other section defines how to access a server. Only private token
85
+ authentication is supported (not user/password).
86
+
87
+ Choosing a different server than the default one can be done at run time:
88
+
89
+ `````
90
+ gitlab --gitlab=distant [command]
91
+ `````
92
+
93
+ gitlab always requires 2 mandatory arguments.
94
+
95
+ The first argument is the object type on which we will act, the second one is
96
+ the action:
97
+
98
+ `````
99
+ gitlab Project list
100
+ `````
101
+
102
+ The usable objects are those which inherits GitlabObject (yes, the source is
103
+ the doc ATM), and the actions are list, get, create, update, delete.
104
+
105
+ Some examples:
106
+
107
+ ````` bash
108
+ # list all the projects:
109
+ gitlab Project list
110
+
111
+ # get a specific project (id 2):
112
+ gitlab Project get 2
113
+
114
+ # get a list of snippets for this project:
115
+ gitlab ProjectIssue list project_id=2
116
+ # (you're right, this syntax sucks)
117
+
118
+ # delete a Snippet (id 3):
119
+ gitlab ProjectSnippet delete 3 project_id=2
120
+
121
+ # update a Snippet:
122
+ gitlab ProjectSnippet update 4 project_id=2 code=" My New Code"
123
+
124
+ # create a Snippet:
125
+ gitlab ProjectSnippet create project_id=2
126
+ Impossible to create object (Missing attribute(s): title, file_name, code)
127
+
128
+ # oops, let's add the attributes:
129
+ gitlab ProjectSnippet create project_id=2 title=" the title" file_name=" the name" code=" the code"
130
+ `````
0 commit comments