Member-only story
Learn how to create beautiful prompts in Python
Enhance your command line interface with questionary
While writing my article on commitizen, I was amazed by the beauty of the command line interface (CLI) and the ease of choosing menu options using the arrow keys. It’s something I’ve always wanted to do, having seen it in various CLIs, but alas, Click doesn’t let you do it.
I dug into the commitizen code to see how it worked and that’s where I discovered the questionary library. Today, we will explore what we can accomplish with this fantastic library by implementing a clone of the command poetry init
. If you don’t know poetry, it is a Python package for dependency management and packaging. You can read my introduction on this topic if you want.
Just to be clear, we will not fully implement the command, things like package conflict resolution or verifying package version syntax are out of the scope of this article for simplicity purposes. You can try to implement them if you wish. 😜