summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2013-01-06 15:32:34 +0100
committerMarc-André Lureau <marcandre.lureau@gmail.com>2013-01-06 16:38:27 +0100
commitb59fbd6870448786dde0431c2a6f97c8b8d969ad (patch)
tree28e88b726cc95b45d395aee64d77fb8ef16041ae
parentf611c00d683144b802714ee13047765eab395e08 (diff)
downloadmsitools-b59fbd6870448786dde0431c2a6f97c8b8d969ad.tar.gz
msitools-b59fbd6870448786dde0431c2a6f97c8b8d969ad.tar.xz
msitools-b59fbd6870448786dde0431c2a6f97c8b8d969ad.zip
Add command line options
-rw-r--r--src/Makefile.am1
-rw-r--r--src/wixl.vala42
2 files changed, 41 insertions, 2 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 87323d1..ce618fb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -10,6 +10,7 @@ AM_VALAFLAGS = \
--pkg libmsi-1.0 \
--pkg libgcab-1.0 \
--pkg libxml-2.0 \
+ --pkg posix \
$(NULL)
wixl_SOURCES = \
diff --git a/src/wixl.vala b/src/wixl.vala
index c2084fd..0c6c2f4 100644
--- a/src/wixl.vala
+++ b/src/wixl.vala
@@ -1,20 +1,58 @@
+using Posix;
+
namespace Wixl {
+static bool version;
+[CCode (array_length = false, array_null_terminated = true)]
+static string[] files;
+
+private const OptionEntry[] options = {
+ { "version", 0, 0, OptionArg.NONE, ref version, N_("Display version number"), null },
+ { "", 0, 0, OptionArg.FILENAME_ARRAY, ref files, null, N_("OUTPUT_FILE INPUT_FILE...") },
+ { null }
+};
+
int main (string[] args) {
Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
Intl.textdomain (Config.GETTEXT_PACKAGE);
+ GLib.Environment.set_application_name (Config.PACKAGE_NAME);
+
+ var parameter_string = _("- a msi building tool");
+ var opt_context = new OptionContext (parameter_string);
+ opt_context.set_help_enabled (true);
+ opt_context.add_main_entries (options, null);
+
+ try {
+ opt_context.parse (ref args);
+ } catch (OptionError.BAD_VALUE err) {
+ GLib.stdout.printf (opt_context.get_help (true, null));
+ exit (1);
+ } catch (OptionError error) {
+ warning (error.message);
+ }
+
+ if (version) {
+ GLib.stdout.printf ("%s\n", Config.PACKAGE_VERSION);
+ exit (0);
+ }
+
+ if (files.length != 2) {
+ GLib.stderr.printf (_("Please specify a output and input files.\n"));
+ exit (1);
+ }
try {
- var file = File.new_for_commandline_arg (args[1]);
+ var file = File.new_for_commandline_arg (files[1]);
string data;
FileUtils.get_contents (file.get_path (), out data);
var doc = Xml.Parser.read_memory (data, data.length);
var root = new WixRoot ();
root.load_xml (doc);
var builder = new WixBuilder (root);
+ builder.add_path (file.get_parent ().get_path ());
var msi = builder.build ();
- msi.build ("foo.msi");
+ msi.build (files[0]);
} catch (GLib.Error error) {
printerr (error.message + "\n");
return 1;