python - Custom Interactive Shell with AutoComplete - Stack Overflow
Recommended library for an interactive CLI?
Menus in Python
Good example of CLI wrapper?
I'm trying to build a simple script. I'd like to present a list of options to a user, then allow the user to tab up and down through the list (using arrows and/or j+k) and select an option with enter.
Bonus points if the library can:
-
present follow up options/questions/commands after selecting an option
-
accept one of multiple keystrokes/commands when selecting the option, not just <enter>
-
refresh the view of the list of options (e.g. if there are associated statuses with each option)
Any suggestions?
Thanks!
ยป pip install cmd2
Try this cmd module from the standard library. It's designed for that purpose.
Python Prompt toolkit is a very good module to use when you want to make a fully featured interactive shell. It comes with all the needed features like :
- Auto-complete (with visual dropdowns)
- Command history and search
- Works cross-platform