]> git.donarmstrong.com Git - dactyl.git/blob - common/components/commandline-handler.js
Initial import of 1.0~b6
[dactyl.git] / common / components / commandline-handler.js
1 // Copyright (c) 2009 by Doug Kearns
2 //
3 // This work is licensed for reuse under an MIT license. Details are
4 // given in the LICENSE.txt file included with this file.
5 "use strict";
6
7 function reportError(e) {
8     dump("dactyl: command-line-handler: " + e + "\n" + (e.stack || Error().stack));
9     Cu.reportError(e);
10 }
11
12 var global = this;
13 var NAME = "command-line-handler";
14 var Cc = Components.classes;
15 var Ci = Components.interfaces;
16 var Cu = Components.utils;
17
18 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
19
20 function CommandLineHandler() {
21     this.wrappedJSObject = this;
22
23     Cu.import("resource://dactyl/base.jsm");
24     require(global, "util");
25     require(global, "config");
26 }
27 CommandLineHandler.prototype = {
28
29     classDescription: "Dactyl Command-line Handler",
30
31     classID: Components.ID("{16dc34f7-6d22-4aa4-a67f-2921fb5dcb69}"),
32
33     contractID: "@mozilla.org/commandlinehandler/general-startup;1?type=dactyl",
34
35     _xpcom_categories: [{
36         category: "command-line-handler",
37         entry: "m-dactyl"
38     }],
39
40     QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsICommandLineHandler]),
41
42     handle: function (commandLine) {
43
44         // TODO: handle remote launches differently?
45         try {
46             this.optionValue = commandLine.handleFlagWithParam(config.name, false);
47         }
48         catch (e) {
49             util.dump("option '-" + config.name + "' requires an argument\n");
50         }
51     },
52
53     get helpInfo() "  -" + config.name + " <opts>" + "             Additional options for " + config.appName + " startup\n".substr(config.name.length)
54 };
55
56 if (XPCOMUtils.generateNSGetFactory)
57     var NSGetFactory = XPCOMUtils.generateNSGetFactory([CommandLineHandler]);
58 else
59     var NSGetModule = XPCOMUtils.generateNSGetModule([CommandLineHandler]);
60 var EXPORTED_SYMBOLS = ["NSGetFactory", "global"];
61
62 // vim: set fdm=marker sw=4 ts=4 et: