{"id":349,"date":"2022-07-24T00:00:00","date_gmt":"2022-07-24T00:00:00","guid":{"rendered":"https:\/\/tac.debuzzify.com\/?p=349"},"modified":"2023-06-20T06:25:26","modified_gmt":"2023-06-20T06:25:26","slug":"create-command-line-tools-in-python","status":"publish","type":"post","link":"https:\/\/www.the-analytics.club\/create-command-line-tools-in-python\/","title":{"rendered":"How to Easily Build Command Line Tools in Python?"},"content":{"rendered":"\n

It’s so much easy to develop a command line tool than a graphical UI<\/a>. But it’s easier in Python now than it was before.<\/p>\n\n\n\n\n\n

Typer<\/a> is a handy tool that helps convert our ordinary functions into command-line utilities.<\/p>\n\n\n\n

A common need in most CLIs is to accept arguments from the user. Typer makes it super easy to do this. Further, Typer also has the flexibility to style your output.<\/p>\n\n\n\n

All this happens in two magical lines of code!<\/p>\n\n\n\n

Here’s a simple Python function that accepts a name and says hello. Two lines of Typer code have changed to a CLI.<\/p>\n\n\n\n

If you’re not using Typer, you can use the standard module, argparser to create CLIs<\/a>. But Typer is so much easier.<\/p>\n\n\n\n

Create your first command line tool in Python.<\/h2>\n\n\n\n

Before you begin with the rest of the guide, please install typer<\/a> on your local computer or your virtual environment. The following code will help.<\/p>\n\n\n\n