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 require("config", global);
21 require("util", global);
24 function CommandLineHandler() {
25 this.wrappedJSObject = this;
27 CommandLineHandler.prototype = {
29 classDescription: "Dactyl command line Handler",
31 classID: Components.ID("{16dc34f7-6d22-4aa4-a67f-2921fb5dcb69}"),
33 contractID: "@mozilla.org/commandlinehandler/general-startup;1?type=dactyl",
37 category: "command-line-handler",
41 // FIXME: Belongs elsewhere
43 category: "profile-after-change",
48 observe: function observe(subject, topic, data) {
49 if (topic === "profile-after-change") {
51 require(global, "main");
55 QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsICommandLineHandler]),
57 handle: function (commandLine) {
60 var remote = commandLine.handleFlagWithParam(config.name + "-remote", false);
63 util.dump("option '-" + config.name + "-remote' requires an argument\n");
68 commandLine.preventDefault = true;
69 require(global, "services");
70 util.dactyl.execute(remote);
78 this.optionValue = commandLine.handleFlagWithParam(config.name, false);
81 util.dump("option '-" + config.name + "' requires an argument\n");
85 get helpInfo() " -" + config.name + " <opts>" + " Additional options for " + config.appName + " startup\n".substr(config.name.length)
88 if (XPCOMUtils.generateNSGetFactory)
89 var NSGetFactory = XPCOMUtils.generateNSGetFactory([CommandLineHandler]);
91 var NSGetModule = XPCOMUtils.generateNSGetModule([CommandLineHandler]);
92 var EXPORTED_SYMBOLS = ["NSGetFactory", "global"];
94 // vim: set fdm=marker sw=4 sts=4 ts=8 et: