prompt-toolkit / prompt-toolkit/python-prompt-toolkit
How to keep a prompt from going into the history
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.6k
- Forks
- 815
- PR merge metrics
- No merged PRs in 30d
Description
The default flag to PromptSession.prompt works well, but I would also like to prevent the defaults from going into the history.
I was thinking I could just remove it from the history immediately after the prompt call, but there doesn't seem to be a method on History to remove items. A pop method would be useful. IMHO History should use one of the collections ABCs so that history classes can be treated like lists.
See also the discussion at https://github.com/jonathanslenders/python-prompt-toolkit/pull/621
Apparently the only way I can currently do this is to use a custom History subclass and somehow pass through to append_string which items shouldn't be saved, which is not a very clean way to do it.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with PromptSession.prompt, the History API, and append_string; review the linked discussion in pull request 621 for the intended behavior. The change should let callers prevent default values from being saved and provide list-like removal such as pop without requiring a custom History subclass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100