Skip to content

2024

Create a Comand line interface in few minutes

cli title

A command line interface could seem an ancient tool to all non expert users, nowadays used to fancy click and drop user interfaces. Nothing more wrong! It is also a valid tool to enhance your libraries and projects, reusable in bash scripts and ci/cd pipelines.

In this tutorial we will deep dive into the python click library and create a simple command line interface (CLI) to manage the settings value and interact with our project.

Manage settings with Pydantic

pydantic-image Pydantic is a wonderful library that allows to easily validate your data, simply defining a schema. It is highly customizable and can be used, for instance, to validate data coming from a POST request.

In this tutorial we will use it to create a Settings class whose fields can be changed in different ways, triggering any time the validation.