Working on command line flags

This commit is contained in:
Sumner Evans
2019-06-06 20:15:16 -06:00
parent 4a79aab3bd
commit 216ffd9f2e
2 changed files with 16 additions and 1 deletions

View File

@@ -1,3 +1,5 @@
import os
from typing import Any, Dict, List, Optional
import json

View File

@@ -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)