From 27e26903fb71d0b2a1a79b47626d30561672668c Mon Sep 17 00:00:00 2001 From: EKNr1 Date: Sat, 7 Dec 2024 20:34:24 +0100 Subject: [PATCH] Implemented that the editor opens the file that gets specified by command line argument. --- main.py | 2 +- utils.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 074677a..42b255a 100755 --- a/main.py +++ b/main.py @@ -22,7 +22,7 @@ class BreadEditor: def run(self): self.gui.post_setup() - self.utils.open_last_file() + self.utils.on_start() self.utils.popup_init() diff --git a/utils.py b/utils.py index b728782..be69e98 100644 --- a/utils.py +++ b/utils.py @@ -106,7 +106,7 @@ class Utils: editor.update_style() - def open_last_file(self): + def on_start(self): if len(sys.argv) == 1: # if no parameters were passed to the editor file_path = self.app.settings.last_opened_file @@ -118,3 +118,10 @@ class Utils: file_path = f"{os.path.dirname(os.path.abspath(__file__))}/example.txt" file = File(self.app, file_path, file_path.split("/")[-1]) self.app.open_files[file_path] = file + + else: + file_path = sys.argv[1] + + if os.path.isfile(file_path): + file = File(self.app, file_path, file_path.split("/")[-1]) + self.app.open_files[file_path] = file