1 // Copyright (c) 2009 by Doug Kearns
3 // This work is licensed for reuse under an MIT license. Details are
4 // given in the LICENSE.txt file included with this file.
7 function reportError(e) {
8 dump("dactyl: command-line-handler: " + e + "\n" + (e.stack || Error().stack));
13 var NAME = "command-line-handler";
14 var { classes: Cc, interfaces: Ci, utils: Cu } = Components;
16 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
19 Cu.import("resource://dactyl/bootstrap.jsm");
20 if (!JSMLoader.initialized)
22 JSMLoader.load("base.jsm", global);
23 require(global, "config");
24 require(global, "util");
27 function CommandLineHandler() {
28 this.wrappedJSObject = this;
30 CommandLineHandler.prototype = {
32 classDescription: "Dactyl command line Handler",
34 classID: Components.ID("{16dc34f7-6d22-4aa4-a67f-2921fb5dcb69}"),
36 contractID: "@mozilla.org/commandlinehandler/general-startup;1?type=dactyl",
40 category: "command-line-handler",
44 // FIXME: Belongs elsewhere
46 category: "profile-after-change",
51 observe: function observe(subject, topic, data) {
52 if (topic === "profile-after-change") {
54 require(global, "main");
58 QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsICommandLineHandler]),
60 handle: function (commandLine) {
63 var remote = commandLine.handleFlagWithParam(config.name + "-remote", false);
66 util.dump("option '-" + config.name + "-remote' requires an argument\n");
71 commandLine.preventDefault = true;
72 require(global, "services");
73 util.dactyl.execute(remote);
81 this.optionValue = commandLine.handleFlagWithParam(config.name, false);
84 util.dump("option '-" + config.name + "' requires an argument\n");
88 get helpInfo() " -" + config.name + " <opts>" + " Additional options for " + config.appName + " startup\n".substr(config.name.length)
91 if (XPCOMUtils.generateNSGetFactory)
92 var NSGetFactory = XPCOMUtils.generateNSGetFactory([CommandLineHandler]);
94 var NSGetModule = XPCOMUtils.generateNSGetModule([CommandLineHandler]);
95 var EXPORTED_SYMBOLS = ["NSGetFactory", "global"];
97 // vim: set fdm=marker sw=4 ts=4 et: