'How to create a custom command prompt in python

We have a CLI tool which uses Typer module in python.

However, I want to create a custom command prompt - like the mysql prompt for example.

mysql>

Currently, the commands are invoked like:

C:\Users\ABC> python wowcli.py command1 paramA paramB
C:\Users\ABC> python wowcli.py command2 paramC paramD

I am trying to achieve something like:

C:\Users\ABC> python wowcli.py
wowcli> command1 paramA paramB
wowcli> command2 paramC paramD

Is there any python library that we can install or otherwise? Please suggest.



Solution 1:[1]

You are looking to build a custom REPL, read evaluate print loop.

Your question is very broad but you can get started here https://dev.to/amal/building-the-python-repl-3468

Solution 2:[2]

I'm not absolutely sure what you mean here. Have a look at input. You can "parse" these arguments with str.split.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Markus Hirsimäki
Solution 2 VideoCarp