|
1 |
| -Command line usage |
2 |
| -================== |
| 1 | +#################### |
| 2 | +``gitlab`` CLI usage |
| 3 | +#################### |
3 | 4 |
|
4 |
| -Document here how to use command line tool |
| 5 | +``python-gitlab`` provides a:command:`gitlab` command-line tool to interact |
| 6 | +with GitLab servers. It uses a configuration file to define how to connect to |
| 7 | +the servers. |
| 8 | + |
| 9 | +Configuration |
| 10 | +============= |
| 11 | + |
| 12 | +Files |
| 13 | +----- |
| 14 | + |
| 15 | +``gitlab`` looks up 2 configuration files by default: |
| 16 | + |
| 17 | +``/etc/python-gitlab.cfg`` |
| 18 | + System-wide configuration file |
| 19 | + |
| 20 | +``~/.python-gitlab.cfg`` |
| 21 | + User configuration file |
| 22 | + |
| 23 | +You can use a different configuration file with the:option:`--config-file` |
| 24 | +option. |
| 25 | + |
| 26 | +Content |
| 27 | +------- |
| 28 | + |
| 29 | +The configuration file uses the ``INI`` format. It contains at least a |
| 30 | +``[global]`` section, and a new section for each GitLab server. For example: |
| 31 | + |
| 32 | +..code-block::ini |
| 33 | +
|
| 34 | + [global] |
| 35 | +default = somewhere |
| 36 | +ssl_verify = true |
| 37 | +timeout = 5 |
| 38 | +
|
| 39 | + [somewhere] |
| 40 | +url = https://some.whe.re |
| 41 | +private_token = vTbFeqJYCY3sibBP7BZM |
| 42 | +
|
| 43 | + [elsewhere] |
| 44 | +url = http://else.whe.re:8080 |
| 45 | +private_token = CkqsjqcQSFH5FQKDccu4 |
| 46 | +timeout = 1 |
| 47 | +
|
| 48 | +The ``default`` option of the ``[global]`` section defines the GitLab server to |
| 49 | +use if no server is explitly specified with the:option:`--gitlab` CLI option. |
| 50 | + |
| 51 | +The ``[global]`` section also defines the values for the default connexion |
| 52 | +parameters. You can override the values in each GitLab server section. |
| 53 | + |
| 54 | +..list-table::Global options |
| 55 | +:header-rows: 1 |
| 56 | + |
| 57 | + * - Option |
| 58 | + - Possible values |
| 59 | + - Description |
| 60 | + * - ``ssl_verify`` |
| 61 | + - ``True`` or ``False`` |
| 62 | + - Verify the SSL certificate. Set to ``False`` if your SSL certificate is |
| 63 | + auto-signed. |
| 64 | + * - ``timeout`` |
| 65 | + - Integer |
| 66 | + - Number of seconds to wait for an answer before failing. |
| 67 | + |
| 68 | +You must define the ``url`` and ``private_token`` in each GitLab server |
| 69 | +section. |
| 70 | + |
| 71 | +..list-table::GitLab server options |
| 72 | +:header-rows: 1 |
| 73 | + |
| 74 | + * - Option |
| 75 | + - Description |
| 76 | + * - ``url`` |
| 77 | + - URL for the GitLab server |
| 78 | + * - ``private_token`` |
| 79 | + - Your user token. Login/password is not supported. |
| 80 | + |
| 81 | +CLI |
| 82 | +=== |
| 83 | + |
| 84 | +Objects and actions |
| 85 | +------------------- |
| 86 | + |
| 87 | +The ``gitlab`` command expects two mandatory arguments. This first one is the |
| 88 | +type of object that you want to manipulate. The second is the action that you |
| 89 | +want to perform. For example: |
| 90 | + |
| 91 | +..code-block::console |
| 92 | +
|
| 93 | + $ gitlab project list |
| 94 | +
|
| 95 | +Use the:option:`--help` option to list the available object types and actions: |
| 96 | + |
| 97 | +..code-block::console |
| 98 | +
|
| 99 | + $ gitlab --help |
| 100 | + $ gitlab project --help |
| 101 | +
|
| 102 | +Some actions require additional parameters. Use the:option:`--help` option to |
| 103 | +list mandatory and optional arguments for an action: |
| 104 | + |
| 105 | +..code-block::console |
| 106 | +
|
| 107 | + $ gitlab project create --help |
| 108 | +
|
| 109 | +Optional arguments |
| 110 | +------------------ |
| 111 | + |
| 112 | +Use the following optional arguments to change the behavior of ``gitlab``. |
| 113 | +These options must be defined before the mandatory arguments. |
| 114 | + |
| 115 | +``--verbose``, ``-v`` |
| 116 | + Outputs detail about retrieved objects. |
| 117 | + |
| 118 | +``--config-file``, ``-c`` |
| 119 | + Path to a configuration file. |
| 120 | + |
| 121 | +``--gitlab``, ``-g`` |
| 122 | + ID of a GitLab server defined in the configuration file. |
| 123 | + |
| 124 | +Example: |
| 125 | + |
| 126 | +..code-block::console |
| 127 | +
|
| 128 | + $ gitlab -v -g elsewhere -c /tmp/gl.cfg project list |