Many people prefer to work from the CLI when possible. This tool aims to bring some of the GitLab functionality into the CLI to avoid repeated trips to the web UI. At this time the tool only allows interaction with snippets.
This tool has only been tested with the following versions of GitLab. Some or all of the features may or may not work with other versions but they are not officially supported.
- 5.1.0
- 5.0.x
How do I get started?
- Clone this repo.
- Make sure you have bundler installed.
gem install bundler
- Run
bundle install
in the root of the repository. - Copy config.yml.sample to config.yml and edit the configuration as appropriate.
- Add the repo bin path to your environment PATH variable.
How can I find the private token for my user?
Login to your GitLab web UI, go to 'My Profile', and select the 'Account' tab. Copy the private token from the box and paste into your config.
How can I add the repo bin path to my environment PATH variable?
Place it in your ~/.bash_profile file. You should end up with something like this:
export PATH=$PATH:/path/to/gitlab-cli/repo/bin/
Note: All command results are subject to user authorization. For example, if the command says it will return all projects it will return all projects...that the user is able to see.
Note2: Anywhere you see [PROJECT] you can either specify the full namespace/project name for the project or you can provide the project ID. Both can be obtained by running the first command below.
gitlab projects
Example output:
3: globalproject1
4: namespace1/project2
6: namespace1/project3
11: namespace2/project1
13: user1/project1
Usage: gitlab snippets [PROJECT]
Using project ID: gitlab snippets 13
Using project full namespace/project format: gitlab snippets user1/project1
Example output:
2: Title - Filename
16: README - README.md
Usage: gitlab snippet view [PROJECT] [SNIPPET_ID]
Using project ID: gitlab snippet view 13 16
Using project full namespace/project format: gitlab snippet view user1/project1 16
Usage: gitlab snippet edit [PROJECT] [SNIPPET_ID]
Using project ID: gitlab snippet edit 13 16
Using project full namespace/project format: gitlab snippet edit user1/project1 16
Example output:
Snippet updated.
URL: https://gitlab.example.com/user1/project1/snippets/16
Usage :gitlab snippet info [PROJECT] [SNIPPET_ID]
Using project ID: gitlab snippet info 13 16
Using project full namespace/project format: gitlab snippet info user1/project1 16
Example output:
Snippet ID: 16
Title: README
File Name: README.md
Author: John Doe <[email protected]>
Created at: Fri Apr 19 01:11:08 UTC 2013
Updated at: Fri Apr 19 01:11:08 UTC 2013
Expires at: Never
Usage 1: gitlab snippet add [PROJECT] [FILE] -t [TITLE] -n [FILE_NAME]
Usage 2: cat [FILE] | gitlab snippet add [PROJECT] -t [TITLE] -n [FILE_NAME]
Using project ID: gitlab snippet add 13 16 /path/to/file -t "Awesome title" -n file.txt
Using project full namespace/project format: `gitlab snippet add user1/project1 16 /path/to/file -t "Awesome title" -n file.txt``
Example output:
Snippet created.
ID: 20
URL: https://gitlab.example.com/user1/project1/snippets/20
Usage: gitlab snippet delete [PROJECT] [SNIPPET_ID]
Using project ID: gitlab snippet delete 13 16
Using project full namespace/project format: gitlab snippet delete user1/project1 16
Note: The "save" subcommand is an alias of "download." Both have the same effect.
Usage 1: gitlab snippet download [PROJECT] [SNIPPET_ID] [FILE]
Usage 2: gitlab snippet save [PROJECT] [SNIPPET_ID] [FILE]
Using project ID: gitlab snippet save 13 16 /path/for/new/file
Using project full namespace/project format: gitlab snippet download user1/project1 16 /path/for/new/file
If you encounter issues with this project, please find help via one of these avenues.
- IRC: #gitlab on Freenode - nick dblessing
- GitHub Issues: Open a new issue here on GitHub
I welcome all contributions. If you would like to include a new feature or bug fix, simply open a pull request and explain the problem or feature you contributed. I will review the contribution at that point. If you want to discuss fixes or improvements before submitting a pull request, please find me on IRC #gitlab on Freenode or open a GitHub issue.
See LICENSE file.