Use our python-cli-tool cookiecutter project. Get an python cli project up and running in a few steps. In my previous speedup-event-driven-projects blog. I wrote how you could use cookiecutter to spin up an event driven project for AWS. In this blog post I will show you how you could do this for python cli projects.
For this blog post I assume that you have the following installed:
Lets create an cli project
We will begin with executing the cookiecutter command:
Cookiecutter will create a folder based on the
project_name. In this folder you now only need to install the dependencies. You can use the following command:
install target of the Makefile will:
- Perform a
poetry init, this will create the
- Create git repository and install the pre-commit hooks.
- Perform a
poetry install. This will install all project dependencies based on the
- Adds extra configuration to the
- Commits everything to the git repository.
You will end up with something like this:
The project itself has unit testing in-place:
And you can test your cli tool as well by executing the commands through poetry:
Now it’s time to configure your remote GitHub repository:
git remote add origin email@example.com:binxio/my-example-cli.git git branch -M main git push -u origin main git checkout -b develop git push --set-upstream origin develop
We pushed the
main branch to the remote and created a
develop branch as a working branch.
The project itself contains the following workflows:
- Continuous Integration, checks when you push to
mainor open a pull request to
- Create Release, creates an release for you when you merge to
mainand uploads it to PyPi.org. (You need to configure a
PYPI_API_TOKENsecret in GitHub for this to work)
- Release Notes, creates a proposal for your release notes. This is based on your merged pull requests. So make sure you use correct messages.
By using the python-cli-tool cookiecutter project you will speedup your python cli project!
And you can focus on what matters! Your business logic!
Photo by Ekaterina Belinskaya