fixed an issue where the entire app would crash if a command failed lol
This commit is contained in:
17
main.py
17
main.py
@@ -45,6 +45,7 @@ class Berry(App):
|
||||
id="file-tabs"
|
||||
)
|
||||
yield TextArea.code_editor(placeholder="This file is empty.", language="python", theme="css", id="code-editor", disabled=True)
|
||||
|
||||
with Vertical(id="console-container"):
|
||||
yield RichLog(id="console")
|
||||
yield Input(placeholder="> ", id="console-input")
|
||||
@@ -62,8 +63,18 @@ class Berry(App):
|
||||
console = self.query_one("#console")
|
||||
|
||||
console.write(f"> {command}")
|
||||
result = subprocess.check_output(command, shell=True, text=True)
|
||||
console.write(result)
|
||||
|
||||
if command == "clear" or command == "cls":
|
||||
console.clear()
|
||||
else:
|
||||
try:
|
||||
result = subprocess.check_output(command, shell=True, text=True)
|
||||
console.write(result)
|
||||
except subprocess.CalledProcessError as e:
|
||||
console.write(e.stdout)
|
||||
|
||||
|
||||
self.query_one("#console-input").focus()
|
||||
|
||||
def action_find(self):
|
||||
try:
|
||||
@@ -177,6 +188,8 @@ class Berry(App):
|
||||
code_editor.language = None
|
||||
code_editor.disabled = False
|
||||
|
||||
code_editor.focus()
|
||||
|
||||
|
||||
@on(Window.Minimized)
|
||||
def window_minimized(self, event: Window.Minimized):
|
||||
|
||||
Reference in New Issue
Block a user