Commits

Vladimir Kolev  committed 17f2ff7

Updated commandline interface to be more intuitive - PROBLEM with the --help option
from gstreamer

  • Participants
  • Parent commits a1773a9

Comments (0)

Files changed (2)

+Usage:
+	gsharkdown.py [OPTION]
+	
+Options:
+	-i, --info			Prints information about the current song
+	-c, --current			Prints the current playing song
+	-s, --state			Prints the current state of the player
+	-v, --version			Prints the current gSharkDown version

File gsharkdown.py

             info = info + "Album:" + song['AlbumName'] + "\n"
             info = info + "Year:" + song['Year'] + "\n"
             return info
-
+        
+    @dbus.service.method(dbus_interface='org.gsharkdown.Single')
+    def get_version(self):
+        """
+        Method to return the current version of gSharkDown.
+        """
+        f = open("%s/VERSION" % BASEPATH, 'r')
+        version = f.read()
+        f.close()
+        return version
+    
+    @dbus.service.method(dbus_interface='org.gsharkdown.Single')
+    def get_help(self):
+        """
+        Method to read the HELP file and display the help message
+        when using the commandline interface.
+        """        
+        return open("%s/HELP" % BASEPATH, 'r').read()
 
 if __name__ == "__main__":
     owner = dbus.bus.REQUEST_NAME_REPLY_PRIMARY_OWNER
         the application and share some informations.
         """
         try:
-            if sys.argv[1] == "current":
+            if sys.argv[1] in ["--current", "-c", "current"]:
                 method = dbus.SessionBus().get_object("org.gsharkdown.Single",
                             "/org/gsharkdown/Single").get_dbus_method("get_current")
-            elif sys.argv[1] == "state":
+            elif sys.argv[1] in ["--state", "-s", "state"]:
                 method = dbus.SessionBus().get_object("org.gsharkdown.Single",
                             "/org/gsharkdown/Single").get_dbus_method("get_state")
-            elif sys.argv[1] == "info":
+            elif sys.argv[1] in ["--info", "-i", "info"]:
                 method = dbus.SessionBus().get_object("org.gsharkdown.Single",
                             "/org/gsharkdown/Single").get_dbus_method("get_info")
+            elif sys.argv[1] in ["--version", "-v","version"]:
+                method = dbus.SessionBus().get_object("org.gsharkdown.Single",
+                            "/org/gsharkdown/Single").get_dbus_method("get_version")
+            elif sys.argv[1] in ["--help", "-h", "help"]:
+                method = dbus.SessionBus().get_object("org.gsharkdown.Single",
+                            "/org/gsharkdown/Single").get_dbus_method("get_help")
             print method()
         except:
-            print "gSharkDown commands:\ncurrent\nstate\ninfo\n"
+            print open("%s/HELP" % BASEPATH, 'r').read()
     else:
         app = SharkDown()
         service = SingleService(app)