From 3c0cb977031e2c396dc1f699ab802a8d8382059a Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Mon, 30 Jan 2023 19:28:27 +0100 Subject: [PATCH] if a file is given on the command line, then open only this file --- krowlog.py | 4 +--- src/plugins/openfileplugin.py | 10 +++++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/krowlog.py b/krowlog.py index c74b5ef..fde81fd 100644 --- a/krowlog.py +++ b/krowlog.py @@ -85,9 +85,7 @@ if __name__ == "__main__": window = PluginRegistry.execute_single("create_main_window") window.show() - PluginRegistry.execute("after_start") - for file in cmd_args.files: - PluginRegistry.execute("open_file", file) + PluginRegistry.execute("after_start", cmd_args.files) register_signal_handler() diff --git a/src/plugins/openfileplugin.py b/src/plugins/openfileplugin.py index f309514..05caf16 100644 --- a/src/plugins/openfileplugin.py +++ b/src/plugins/openfileplugin.py @@ -85,9 +85,13 @@ class OpenFilePlugin(PluginBase): def after_open_file(self, file: str): self._remember_recent_file(file) - def after_start(self): - open_files_as_string = self.settings.get_session('general', 'open_files', fallback='') - files = open_files_as_string.split(os.pathsep) + def after_start(self, files_from_command_line: [str]): + + if files_from_command_line: + files = files_from_command_line + else: + open_files_as_string = self.settings.get_session('general', 'open_files', fallback='') + files = open_files_as_string.split(os.pathsep) if "" in files: files.remove("") for file in files: