gh-119548: Add a 'clear' command to the REPL (#119549)

This commit is contained in:
Pablo Galindo Salgado 2024-05-25 17:15:54 +01:00 committed by GitHub
parent a531fd7fdb
commit e3bac04c37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 1 deletions

View file

@ -57,12 +57,17 @@ def _strip_final_indent(text: str) -> str:
return text
def _clear_screen():
reader = _get_reader()
reader.scheduled_commands.append("clear_screen")
REPL_COMMANDS = {
"exit": _sitebuiltins.Quitter('exit', ''),
"quit": _sitebuiltins.Quitter('quit' ,''),
"copyright": _sitebuiltins._Printer('copyright', sys.copyright),
"help": "help",
"clear": "clear_screen",
"clear": _clear_screen,
}
class InteractiveColoredConsole(code.InteractiveConsole):