[gnome-code-assistance/wip/vala: 16/20] [backends/vala] Move options into application



commit 2d11e654be122e9ad8191034d17cc726fd279c09
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Fri Nov 15 13:08:40 2013 +0100

    [backends/vala] Move options into application

 backends/vala/Makefile.am      |    1 -
 backends/vala/application.vala |   23 +++++++++++++++++--
 backends/vala/options.vala     |   45 ----------------------------------------
 3 files changed, 20 insertions(+), 49 deletions(-)
---
diff --git a/backends/vala/Makefile.am b/backends/vala/Makefile.am
index 6819a62..21a5abd 100644
--- a/backends/vala/Makefile.am
+++ b/backends/vala/Makefile.am
@@ -3,7 +3,6 @@ valabackend_PROGRAMS = backends/vala/vala
 
 backends_vala_vala_SOURCES =                   \
        backends/vala/application.vala          \
-       backends/vala/options.vala              \
        backends/vala/types.vala                \
        backends/vala/dbus.vala                 \
        backends/vala/diagnostics.vala          \
diff --git a/backends/vala/application.vala b/backends/vala/application.vala
index 8356219..356efd4 100644
--- a/backends/vala/application.vala
+++ b/backends/vala/application.vala
@@ -22,14 +22,31 @@ namespace Gca.Backends.Vala
 
 public class Application
 {
+       static string transport;
+       static string address;
+
+       static void init_options()
+       {
+               transport = "dbus";
+               address = ":0";
+       }
+
+       const GLib.OptionEntry[] options = {
+               { "transport", 't', 0, OptionArg.STRING, ref transport, "the transport (dbus or http)", 
"TRANSPORT" },
+               { "address", 'a', 0, OptionArg.STRING, ref address, "the http address to listen on", 
"ADDRESS" },
+
+               // list terminator
+               { null }
+       };
+
        public static int main(string[] args)
        {
-               Options.init();
+               init_options();
 
                var ctx = new OptionContext("- gnome code assistance daemon");
 
                ctx.set_help_enabled(true);
-               ctx.add_main_entries(Options.options, null);
+               ctx.add_main_entries(options, null);
 
                try
                {
@@ -42,7 +59,7 @@ public class Application
                        return 1;
                }
 
-               if (Options.transport == "dbus")
+               if (transport == "dbus")
                {
                        (new DBus.Transport()).run();
                }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]