`import readline` to allow backspace in CLI.
- Cookiecutter version: '1.4.0'
- Template project url: https://github.com/drivendata/cookiecutter-data-science
- Python version: 3.5.2
- Operating System: macOS 10.12.3
Description:
Importing the readline package would allow users to backspace in the prompts without it rendering as ^H. No other change would be needed.
Hi @aryamccarthy! 👋
Thank you for opening an issue. I'm afraid I don't quite understand.
Are you referring to the built-in readlin package?
Hi, @hackebrot! Thanks for writing.
Yes, that's the one I'm referring to. This StackOverflow discussion explains that simply importing the readline package alters how input() works.
I have sloppy fingers, and I make mistakes when trying to set up my cookiecutter templates. Backspace and arrow keys working as expected would let me fix those instead of quitting the program and starting all over.
Cookiecutter uses click for prompting. We never call input() directly.
Hmm. Is there a click-compatible way to improve this functionality?
Hey @hackebrot, any updates on that topic?
I seem to run into the same problem of @aryamccarthy. During the cookiecutter CLI "question" process I occasionaly have to hit the backspace - which messes up the variables.
For every backspace I get an ? into the variable name. Assuming that my repo is named my_repo but I first wrote my_repu and hit backspace one to change it to my_repo, cookiecutter will give me my_repo?u instead of my_repo.
I hope this makes the issue a bit clearer.
Cheers Joshua
@hackebrot , +1 for jgoerner's comment above.
+1 I just encountered the same problem. Backspace in the prompt window renders as ^H on MacOSX.
Also encountering the same problem, anyone trying to fix this?
Same problem on Ubuntu (WSL2)
Adding a local extension with import readline works as a workaround for me.
cookiecutter.json
{
...
"_extensions": ["local_extensions.fix_readline"]
}
local_extensions.py
import readline
from cookiecutter.utils import simple_filter
@simple_filter
def fix_readline():
pass