Skip to content

Commit

Permalink
Handle server exit when running server-side repl
Browse files Browse the repository at this point in the history
  • Loading branch information
MaddyGuthridge committed Apr 7, 2024
1 parent ada79f0 commit bcf0965
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion flapi/cli/repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import code
import click
import sys
import os
import time
import random
from typing import Optional
Expand All @@ -22,6 +23,7 @@
fl_print,
)
from flapi import _consts as consts
from flapi.errors import FlapiServerExit
from flapi.cli import consts as cli_consts
from .util import handle_verbose
try:
Expand Down Expand Up @@ -78,7 +80,9 @@ def ellipsis(delta: float) -> str:
end='\r',
)

print("Connected to FL Studio")
# Yucky thing to ensure that we write all the way to the end of the line
msg = "Connected to FL Studio"
print(msg + ' ' * (os.get_terminal_size().columns - len(msg)))
return True


Expand Down Expand Up @@ -118,6 +122,12 @@ def exec_lines(lines: list[str]) -> bool:
else:
res = fl_eval(source)
print(repr(res))
except FlapiServerExit:
print(
"Error: the Flapi server exited, likely because FL Studio was "
"closed."
)
exit(1)
except Exception:
print_exc()

Expand Down

0 comments on commit bcf0965

Please sign in to comment.