mirror of
https://github.com/caelestia-dots/cli.git
synced 2026-06-16 05:49:59 -05:00
fix: handle ctrl+c/d cleanly
Also add newline before pause prompt
This commit is contained in:
@@ -42,10 +42,18 @@ def fatal(msg: str) -> None:
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def _input(prompt: str) -> str:
|
||||
try:
|
||||
return input(prompt)
|
||||
except (KeyboardInterrupt, EOFError):
|
||||
print()
|
||||
raise KeyboardInterrupt()
|
||||
|
||||
|
||||
def prompt(msg: str) -> str:
|
||||
return input(_format_msg(36, msg) + " ")
|
||||
return _input(_format_msg(36, msg) + " ")
|
||||
|
||||
|
||||
def pause() -> None:
|
||||
input("\033[2m\033[3m(Ctrl+C to exit, enter to continue)\033[0m")
|
||||
print("\033[1A\r\033[2K", end="") # Clear pause prompt
|
||||
_input("\n\033[2m\033[3m(Ctrl+C to exit, enter to continue)\033[0m")
|
||||
print("\033[1A\r\033[2K\033[1A\r\033[2K", end="") # Clear pause prompt
|
||||
|
||||
Reference in New Issue
Block a user