fix: add clearScreen function and handle exceptions in systemCommand
This commit is contained in:
parent
a8136a7ff4
commit
9da95ee850
@ -19,15 +19,23 @@ def clearCondition(command: str) -> bool:
|
|||||||
return command in ["c", "clear", "cls"]
|
return command in ["c", "clear", "cls"]
|
||||||
|
|
||||||
|
|
||||||
|
def clearScreen():
|
||||||
|
print(run_command("clear"))
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def systemCommand(command: str) -> str:
|
def systemCommand(command: str) -> str:
|
||||||
words = command[1:].split()
|
words = command[1:].split()
|
||||||
if words[0] == "":
|
if words[0] == "":
|
||||||
return "Command not found. Write 'h' for help."
|
return "Command not found. Write 'h' for help."
|
||||||
print(
|
try:
|
||||||
run_command(
|
print(
|
||||||
f'docker exec -it webscraper {" ".join(words)}',
|
run_command(
|
||||||
|
f'docker exec -it webscraper {" ".join(words)}',
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
except Exception as e:
|
||||||
|
print(f"An error occurred: {e}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ def prompt():
|
|||||||
print(help_list())
|
print(help_list())
|
||||||
continue
|
continue
|
||||||
if clearCondition(command):
|
if clearCondition(command):
|
||||||
run_command("clear")
|
clearScreen()
|
||||||
continue
|
continue
|
||||||
if command.startswith("$"):
|
if command.startswith("$"):
|
||||||
systemCommand(command)
|
systemCommand(command)
|
||||||
|
Loading…
Reference in New Issue
Block a user