GitLab CLI is a small command-line tool for interacting with GitLab repositories. It allows users to configure their GitLab credentials, list repositories, and perform various operations such as cloning and updating repositories.
- Install Python Libraries and download script.
Using wget:
pip install click pre-commit python-gitlab rich && \
wget https://raw.githubusercontent.com/icmtf/gl_cli/refs/heads/master/gl_cli.pyUsing cURL:
pip install click python-gitlab rich && \
curl https://raw.githubusercontent.com/icmtf/gl_cli/refs/heads/master/gl_cli.py \
-o gl_cli.py- Run the script.
python gl_cli.py check- Python 3.10+
- Installed libraries: click, python-gitlab, rich
-
Clone this repository:
git clone <REPOSITORY_URL> -
Navigate to the project directory:
cd <DIRECTORY_NAME> -
Install the required dependencies:
pip install -r requirements.txt
Before using the tool, you need to configure the GitLab instance URL and private token. You can do this using the command:
python gl_cli.py config
Alternatively, you can set the environment variables GITLAB_URL and GITLAB_TOKEN.
To check if your GitLab token and URL are working correctly:
python gl_cli.py check
To display a list of available repositories:
python gl_cli.py list-repos
To clone all repositories into a specified directory:
python gl_cli.py repo clone --dir <DIRECTORY_PATH>
To clone all repositories, overwriting existing ones:
python gl_cli.py repo clone-overwrite --dir <DIRECTORY_PATH>
To update existing repositories in a specified directory:
python gl_cli.py repo clone-update --dir <DIRECTORY_PATH>
The project includes a pre-commit configuration that uses the following tools:
- Ruff: for linting and formatting Python code
- Bandit: for Python code security analysis
To install pre-commit hooks, run:
pre-commit install
gl_cli.py: Main CLI script.pre-commit-config.yaml: Pre-commit configuration.ruff.toml: Configuration for Ruffpyproject.toml: Configuration for Bandit and other Python tools
MIT
