Skip to content

repl shortcut function #528

Open
Open
@asmeurer

Description

@asmeurer

An idea from #519 (comment) and #519 (comment).

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 #519 (comment)).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions