add cmd arguments to open files
This commit is contained in:
20
krowlog.py
20
krowlog.py
@@ -1,3 +1,4 @@
|
||||
import argparse
|
||||
import logging
|
||||
import signal
|
||||
from PySide6 import QtCore
|
||||
@@ -54,7 +55,24 @@ def init_plugins():
|
||||
PluginRegistry.load_plugin("FilesBrowserPlugin")
|
||||
|
||||
|
||||
class CmdArgs:
|
||||
def __init__(self, files: [str]):
|
||||
self.files = files
|
||||
|
||||
def __str__(self):
|
||||
return f"files={self.files}"
|
||||
|
||||
|
||||
def parse_command_line_parameters() -> CmdArgs:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('files', metavar='F', type=str, nargs='*', help='file(s) to open')
|
||||
namespace = parser.parse_args()
|
||||
return CmdArgs(files=namespace.files)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
cmd_args = parse_command_line_parameters()
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
app.setWindowIcon(Icon(constants.krow_icon)) # works only for Linux (but only X11, not Wayland)
|
||||
|
||||
@@ -68,6 +86,8 @@ if __name__ == "__main__":
|
||||
window.show()
|
||||
|
||||
PluginRegistry.execute("after_start")
|
||||
for file in cmd_args.files:
|
||||
PluginRegistry.execute("open_file", file)
|
||||
|
||||
register_signal_handler()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user