|
Node 18+
|
Install with npm install -g @gitbeaker/cli, or yarn add -g @gitbeaker/cli
```bash
gitbeaker [service name] [method name] --config_args pos_arg1 pos_argN --opts_arg1 --opts_argN
# A shorthand can also be used:
gb [service name] [method name] --config_args pos_arg1 pos_argN --opts_arg1 --opts_argN
```
Where:
- `service name` is any of the supported API names of the [@gitbeaker/rest](https://github.com/jdalrymple/gitbeaker/blob/main/packages/rest/README.md) sdk
- `method name` is any of the supported commands on that API service (See source for exceptions, but generally all, show, remove, update)
- `--config_args` is any of general configuration arguments such as your personal token. These are outlined in this [table](https://github.com/jdalrymple/gitbeaker/blob/main/README.md?#api-client) and can also be found by looking at the cli help menu. These arguments must also include a `gb` or `gl` prefix. ie.
```bash
# To get all the projects
gitbeaker projects all --gb-token="personaltoken"
```
- `pos_arg1 ... pos_argN` are any of the arguments you would normally supply to the function. The names of the args should match the names in the method headers. These positional arguments can also be written as flag arguments: `--pos_arg1 ... --pos_argN`, **BUT** must be written in the correct order.
- `--opts_arg1 ...--opts_argN` are any of the optional arguments that you would normally supply to the function. Their names should match what the GitLab API docs request.
```bash
# To get all the projects id=2 and optional parameter "search" = "cool"
gitbeaker projects all --gb-token="personaltoken" 2 --search="cool"
```
To reduce the annoyance of having to pass those configuration properties each time, it is also possible to pass the token and host information through environment variables in the form of `GITLAB_[option name]` or `GITBEAKER_[option name]` ie:
```bash
GITLAB_HOST=http://example.com
GITLAB_TOKEN=personaltoken
GITBEAKER_CAMELIZE=true
```
|