From 216ffd9f2eed9b0ceb05f96ebc245084fdf57077 Mon Sep 17 00:00:00 2001 From: Sumner Evans Date: Thu, 6 Jun 2019 20:15:16 -0600 Subject: [PATCH] Working on command line flags --- libremsonic/config.py | 2 ++ libremsonic/ui/app.py | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/libremsonic/config.py b/libremsonic/config.py index e446676..d6382c6 100644 --- a/libremsonic/config.py +++ b/libremsonic/config.py @@ -1,3 +1,5 @@ +import os + from typing import Any, Dict, List, Optional import json diff --git a/libremsonic/ui/app.py b/libremsonic/ui/app.py index b04d6b1..9731eb5 100644 --- a/libremsonic/ui/app.py +++ b/libremsonic/ui/app.py @@ -2,7 +2,7 @@ import os import gi gi.require_version('Gtk', '3.0') -from gi.repository import Gio, Gtk +from gi.repository import Gio, Gtk, GLib from libremsonic.config import get_config, save_config @@ -15,13 +15,26 @@ class LibremsonicApp(Gtk.Application): super().__init__( *args, application_id="com.sumnerevans.libremsonic", + flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE, **kwargs, ) self.window = None + self.add_main_option( + 'config', ord('c'), GLib.OptionFlags.NONE, GLib.OptionArg.NONE, + 'Specify a configuration file. Defaults to ~/.config/libremsonic/config.json', + None) + # TODO load this from the config file self.config = None + def do_command_line(self, command_line): + options = command_line.get_options_dict().end().unpack() + print(options) + + self.activate() + return 0 + def do_startup(self): Gtk.Application.do_startup(self)