glab api
glab is GitLab’s command-line client, a Go program GitLab’s engineers own and maintain, and the client a model drives when it works a GitLab project from a terminal, as in gitlab-contribution. Its api subcommand is the raw request: a call to any REST or GraphQL endpoint with the token glab already holds, --field and --raw-field turning key=value pairs into parameters. The changes in the rail are mine, inside the maintainers’ command; each closes a gap between how a request reads and what goes out on the wire.
- A
--fieldvalue opening with[or{decodes as JSON, numbers at full precision, trailing text an error;--raw-fieldsends the same text as a string. - Names are never parsed. On
GETandDELETEthe fields become a query string, whereids[]andposition[base_sha]arrive percent-encoded as the parameters they spell. - Both flags collect into one ordered list, so
-f 'ids[]=1' -f 'ids[]=2'sends both values in the order typed.-F 'ids=[1,2]'emits the same repeats, so spelling one parameter both ways is an error: nothing says which order the values belong in. - On every other method, unless
--inputsupplies the body, the fields are a JSON body, and a bracketed name is an error: it would go out as one literal key the API ignores, and the request would succeed without doing what was asked. --paginatefollows theLinkheader’srel="next"URL as given. It already carries the first request’s parameters, so on a query method the fields are dropped after page one; rebuilding them would double array values and let a caller’spage=1override the server’s page. Other methods keep sending their body.
Outside api, mr create --draft and mr update --draft share one helper that knows every marker GitLab reads as a draft, Draft:, [Draft] and (Draft) in any case, so a marked title is not prefixed again.
The rules in full are glab’s own api reference, generated from the command’s help.