I'm using input()
to ask a user for a command in a Python (3) CLI script.
I'd like them to be able to press ↑ to reuse older commands. For that matter I'd like them to be able to do other basic line editing too.
I can get these features by running rlwrap myscript.py
but I'd rather not have to run the wrapper script. (yes I could set up an alias but I'd like to encapsulate it in-script if poss)
Is there a library to enable this (e.g. provide a history/editing aware version of input()
) or would I need to start from scratch?
readline
but it may need more changes - every commanad has to be in separated functiondo_commandname()
. Similar cmd2 with more functions. – Somatic