avatar Bite 355. Create Your First Typer Command Line Interface (CLI) Application

In the previous Bites, you have successfully transformed an existing script into a CLI using typer.run().

In this Bite, you will create a CLI application including more than one command to run, leveraging app = typer.Typer(). See the Commands documentation for reference.

So, create a command sum that sums two numbers and a command compare that compares two numbers:

$ python script.py sum 3 5
The sum is 8

$ python script.py compare 3 5
d=5 is greater than c=3

Check out the tests for more information on how to format the output.

Login and get coding
go back Beginner level
Bitecoin 2X

11 out of 12 users completed this Bite.
Will you be Pythonista #12 to crack this Bite?
Resolution time: ~45 min. (avg. submissions of 5-240 min.)

Focus on this Bite hiding sidebars, turn on Focus Mode.
We use Python 3.8