Heading image

This is Day 10 of the #100DaysOfPython challenge.

This post will use the PyInquirer library to demonstrate how to add some command line prompts to make it easier to build an interactive program.

It will build off the work done on learning Python Fire basics in a previous blog post.


  1. Building CLIs with Python.

Getting started

You should already have the code. In that blog post, all code was posted into a hello-fire directory with cli.py as the main file with a few dependencies already installed.

The code is available on my GitHub repo.

We are going to add the PyInquirer to our dependencies to use in the cli.py file:

At this stage, we had a cli.py file that looks like the following:

Opening the virtual environment and running python cli.py [command] would run the program (ie python cli.py digestion run would output Burp!).

Simple input prompt

We do this with Python Fire as a call without an value for the argument would raise an error.

We can import the prompt function and use that to get the input:

Now if we run our command line call python cli.py digestion run:

A simple input prompt is all we need to get started.

Note: We could have simply removed volume altogether but we have left is so that Python Fire can cast the input into an int via a flag --volume without a prompt.

Working with dialogs

Update the DigestionStage to look like the following:

We have no added digestion breakfast command that we can run with python run digestion breakfast:

Now we have a digestion breakfast command that will run the breakfast method and output the result of our input into the dialog.


There are many examples that they have on their GitHub if you would like to learn more.

Resources and further reading

  1. Building CLIs with Python Fire
  2. Pipenv
  3. PyInquirer
  4. More examples of PyInquirer
  5. Python Fire

Photo credit: pawel_czerwinski

Originally posted on my blog. To see new posts without delay, read the posts there and subscribe to my newsletter.

I write content for AWS, Kubernetes, Python, JavaScript and more. To view all the latest content, be sure to visit my blog and subscribe to my newsletter. Follow me on Twitter.



Senior Engineer @ Visibuild

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store