prompt-toolkit / prompt-toolkit/python-prompt-toolkit

repl shortcut function

Open
#528 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
10.6k
Forks
815
PR merge metrics
No merged PRs in 30d

Description

An idea from https://github.com/jonathanslenders/python-prompt-toolkit/issues/519#issuecomment-318978114 and https://github.com/jonathanslenders/python-prompt-toolkit/issues/519#issuecomment-320065017.

It could be useful to have one higher level of abstraction in shortcuts.py, for the full "main loop" of a prompt REPL. Something like

def repl(execute_callback, message='', **kwargs):
    while True:
        try:
            res = prompt(message, **kwargs)
        except KeyboardInterrupt:
            print("KeyboardInterrupt", file=sys.stderr)
            continue
        except (EOFError, SystemExit):
            break
        execute_callback(res) # Perhaps the callback should also be passed the cli instance

It could also support other features like keeping track of prompt numbers, or an input "queue" (see https://github.com/jonathanslenders/python-prompt-toolkit/issues/519#issuecomment-318978114).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading shortcuts.py and the two linked discussions from issue #519. Clarify the intended scope of the REPL abstraction, including callback handling, interrupts, exits, prompt numbers, and an input queue. Done means the API and supported behavior are agreed and implemented with coverage for the selected features.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.