mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-10 01:15:46 +01:00
Accept command line arguments in :rehash. Document :rehash, add :exttoggle, :extrehash.
--HG-- branch : bootstrapped
This commit is contained in:
@@ -162,7 +162,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
template.usage(results, params.format));
|
template.usage(results, params.format));
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
argCount: "*",
|
argCount: "0",
|
||||||
completer: function (context, args) {
|
completer: function (context, args) {
|
||||||
context.keys.text = util.identity;
|
context.keys.text = util.identity;
|
||||||
context.keys.description = function () seen[this.text] + " matching items";
|
context.keys.description = function () seen[this.text] + " matching items";
|
||||||
@@ -1176,14 +1176,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
* @see Commands#parseArgs
|
* @see Commands#parseArgs
|
||||||
*/
|
*/
|
||||||
parseCommandLine: function (cmdline) {
|
parseCommandLine: function (cmdline) {
|
||||||
const options = [
|
|
||||||
[["+u"], CommandOption.STRING],
|
|
||||||
[["++noplugin"], CommandOption.NOARG],
|
|
||||||
[["++cmd"], CommandOption.STRING, null, null, true],
|
|
||||||
[["+c"], CommandOption.STRING, null, null, true]
|
|
||||||
].map(CommandOption.fromArray, CommandOption);
|
|
||||||
try {
|
try {
|
||||||
return commands.parseArgs(cmdline, { options: options, argCount: "*" });
|
return commands.get("rehash").parseArgs(cmdline);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
dactyl.reportError(e, true);
|
dactyl.reportError(e, true);
|
||||||
@@ -1688,15 +1682,32 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
filter: function ({ item }) !item.userDisabled,
|
filter: function ({ item }) !item.userDisabled,
|
||||||
perm: "disable"
|
perm: "disable"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "extr[ehash]",
|
||||||
|
description: "Reload an extension",
|
||||||
|
action: function (addon) {
|
||||||
|
dactyl.assert(dactyl.has("Gecko2"), "This command is not useful in this version of " + config.host);
|
||||||
|
util.timeout(function () {
|
||||||
|
addon.userDisabled = true;
|
||||||
|
addon.userDisabled = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
filter: function ({ item }) !item.userDisabled,
|
||||||
|
perm: "disable"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "extt[oggle]",
|
||||||
|
description: "Toggle an extension's enabled status",
|
||||||
|
action: function (addon) addon.userDisabled = !addon.userDisabled
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "extu[pdate]",
|
name: "extu[pdate]",
|
||||||
description: "Update an extension",
|
description: "Update an extension",
|
||||||
actions: updateAddons,
|
actions: updateAddons,
|
||||||
filter: function ({ item }) !item.userDisabled,
|
|
||||||
perm: "upgrade"
|
perm: "upgrade"
|
||||||
}
|
}
|
||||||
].forEach(function (command) {
|
].forEach(function (command) {
|
||||||
let perm = AddonManager["PERM_CAN_" + command.perm.toUpperCase()];
|
let perm = command.perm && AddonManager["PERM_CAN_" + command.perm.toUpperCase()];
|
||||||
function ok(addon) !perm || addon.permissions & perm;
|
function ok(addon) !perm || addon.permissions & perm;
|
||||||
commands.add([command.name],
|
commands.add([command.name],
|
||||||
command.description,
|
command.description,
|
||||||
@@ -1877,7 +1888,31 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
|
|
||||||
commands.add(["reh[ash]"],
|
commands.add(["reh[ash]"],
|
||||||
"Reload the " + config.appName + " add-on",
|
"Reload the " + config.appName + " add-on",
|
||||||
function () { util.rehash(); });
|
function (args) { util.rehash(args); },
|
||||||
|
{
|
||||||
|
argCount: "0",
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
names: ["+u"],
|
||||||
|
description: "The initialization file to execute at startup",
|
||||||
|
type: CommandOption.STRING
|
||||||
|
},
|
||||||
|
{
|
||||||
|
names: ["++noplugin"],
|
||||||
|
description: "Do not automatically load plugins"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
names: ["++cmd"],
|
||||||
|
description: "Ex commands to execute prior to initialization",
|
||||||
|
multiple: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
names: ["+c"],
|
||||||
|
description: "Ex commands to execute after initialization",
|
||||||
|
multiple: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
commands.add(["res[tart]"],
|
commands.add(["res[tart]"],
|
||||||
"Force " + config.appName + " to restart",
|
"Force " + config.appName + " to restart",
|
||||||
@@ -2106,10 +2141,15 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
if (!services.commandLineHandler)
|
if (!services.commandLineHandler)
|
||||||
services.add("commandLineHandler", "@mozilla.org/commandlinehandler/general-startup;1?type=" + config.name);
|
services.add("commandLineHandler", "@mozilla.org/commandlinehandler/general-startup;1?type=" + config.name);
|
||||||
|
|
||||||
if (services.commandLineHandler) {
|
try {
|
||||||
let commandline = services.commandLineHandler.optionValue;
|
if (services.fuel)
|
||||||
if (commandline) {
|
var args = services.fuel.storage.get("dactyl.commandlineArgs", null);
|
||||||
let args = dactyl.parseCommandLine(commandline);
|
if (!args) {
|
||||||
|
let commandline = services.commandLineHandler.optionValue;
|
||||||
|
if (commandline)
|
||||||
|
args = dactyl.parseCommandLine(commandline);
|
||||||
|
}
|
||||||
|
if (args) {
|
||||||
dactyl.commandLineOptions.rcFile = args["+u"];
|
dactyl.commandLineOptions.rcFile = args["+u"];
|
||||||
dactyl.commandLineOptions.noPlugins = "++noplugin" in args;
|
dactyl.commandLineOptions.noPlugins = "++noplugin" in args;
|
||||||
dactyl.commandLineOptions.postCommands = args["+c"];
|
dactyl.commandLineOptions.postCommands = args["+c"];
|
||||||
@@ -2117,6 +2157,9 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
util.dump("Processing command-line option: " + commandline);
|
util.dump("Processing command-line option: " + commandline);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (e) {
|
||||||
|
dactyl.echoerr("Parsing command line options: " + e);
|
||||||
|
}
|
||||||
|
|
||||||
dactyl.log("Command-line options: " + util.objectToString(dactyl.commandLineOptions), 3);
|
dactyl.log("Command-line options: " + util.objectToString(dactyl.commandLineOptions), 3);
|
||||||
|
|
||||||
|
|||||||
@@ -358,6 +358,28 @@ want to bypass &dactyl.appName;'s key handling and pass keys directly to
|
|||||||
</description>
|
</description>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<tags>:reh :rehash</tags>
|
||||||
|
<spec>:reh<oa>ash</oa> <oa>arg</oa> …</spec>
|
||||||
|
<description>
|
||||||
|
<p>
|
||||||
|
Reload the &dactyl.appName; add-on, including all code, plugins,
|
||||||
|
and configuration. For users running directly from the development
|
||||||
|
repository, this is a good way to update to the latest version or
|
||||||
|
to test your changes.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Any arguments supplied are parsed as command line arguments as
|
||||||
|
specified in <t>startup-options</t>.
|
||||||
|
</p>
|
||||||
|
<warning>
|
||||||
|
Not all plugins are designed to cleanly un-apply during a rehash.
|
||||||
|
While official plugins are safe, beware of possibility instability
|
||||||
|
if you rehash while running third-party plugins.
|
||||||
|
</warning>
|
||||||
|
</description>
|
||||||
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>:re :reload</tags>
|
<tags>:re :reload</tags>
|
||||||
<spec>:re<oa>load</oa><oa>!</oa></spec>
|
<spec>:re<oa>load</oa><oa>!</oa></spec>
|
||||||
|
|||||||
@@ -153,10 +153,33 @@
|
|||||||
</description>
|
</description>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<tags>:extr :extrehash</tags>
|
||||||
|
<spec>:extr<oa>ehash</oa> <a>extension</a></spec>
|
||||||
|
<spec>:extr<oa>ehash</oa></spec>
|
||||||
|
<description>
|
||||||
|
<p>
|
||||||
|
Toggle an extension's enabled status twice. This is useful for rebooting
|
||||||
|
a restartless extension.
|
||||||
|
</p>
|
||||||
|
</description>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<tags>:extt :exttoggle</tags>
|
||||||
|
<spec>:extt<oa>oggle</oa> <a>extension</a></spec>
|
||||||
|
<spec>:extt<oa>oggle</oa></spec>
|
||||||
|
<description>
|
||||||
|
<p>
|
||||||
|
Toggle an extension's enabled status.
|
||||||
|
</p>
|
||||||
|
</description>
|
||||||
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>:extu :extupdate</tags>
|
<tags>:extu :extupdate</tags>
|
||||||
<spec>:extu<oa>pdate</oa> <a>extension</a></spec>
|
<spec>:extu<oa>pdate</oa> <a>extension</a></spec>
|
||||||
<spec>:extu<oa>pdate</oa>!</spec>
|
<spec>:extu<oa>pdate</oa><oa>!</oa></spec>
|
||||||
<description>
|
<description>
|
||||||
<p>
|
<p>
|
||||||
Update an extension. When <oa>!</oa> is given, update all
|
Update an extension. When <oa>!</oa> is given, update all
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ var Services = Module("Services", {
|
|||||||
this.add("extensionManager", "@mozilla.org/extensions/manager;1", Ci.nsIExtensionManager);
|
this.add("extensionManager", "@mozilla.org/extensions/manager;1", Ci.nsIExtensionManager);
|
||||||
this.add("favicon", "@mozilla.org/browser/favicon-service;1", Ci.nsIFaviconService);
|
this.add("favicon", "@mozilla.org/browser/favicon-service;1", Ci.nsIFaviconService);
|
||||||
this.add("focus", "@mozilla.org/focus-manager;1", Ci.nsIFocusManager);
|
this.add("focus", "@mozilla.org/focus-manager;1", Ci.nsIFocusManager);
|
||||||
this.add("fuel", "@mozilla.org/fuel/application;1", Ci.fuelIApplication);
|
this.add("fuel", "@mozilla.org/fuel/application;1", Ci.extIApplication);
|
||||||
this.add("history", "@mozilla.org/browser/global-history;2", [Ci.nsIBrowserHistory, Ci.nsIGlobalHistory3,
|
this.add("history", "@mozilla.org/browser/global-history;2", [Ci.nsIBrowserHistory, Ci.nsIGlobalHistory3,
|
||||||
Ci.nsINavHistoryService, Ci.nsPIPlacesDatabase]);
|
Ci.nsINavHistoryService, Ci.nsPIPlacesDatabase]);
|
||||||
this.add("io", "@mozilla.org/network/io-service;1", Ci.nsIIOService);
|
this.add("io", "@mozilla.org/network/io-service;1", Ci.nsIIOService);
|
||||||
|
|||||||
@@ -1187,7 +1187,9 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
getSource: function regexp_getSource(re) re.source.replace(/\\(.)/g, function (m0, m1) m1 === "/" ? "/" : m0)
|
getSource: function regexp_getSource(re) re.source.replace(/\\(.)/g, function (m0, m1) m1 === "/" ? "/" : m0)
|
||||||
}),
|
}),
|
||||||
|
|
||||||
rehash: function () {
|
rehash: function (args) {
|
||||||
|
if (services.fuel)
|
||||||
|
services.fuel.storage.set("dactyl.commandlineArgs", args);
|
||||||
this.timeout(function () {
|
this.timeout(function () {
|
||||||
this.rehashing = true;
|
this.rehashing = true;
|
||||||
this.addon.userDisabled = true;
|
this.addon.userDisabled = true;
|
||||||
@@ -1443,6 +1445,8 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
*/
|
*/
|
||||||
xmlToDom: function xmlToDom(node, doc, nodes) {
|
xmlToDom: function xmlToDom(node, doc, nodes) {
|
||||||
XML.prettyPrinting = false;
|
XML.prettyPrinting = false;
|
||||||
|
if (typeof node === "string") // Sandboxes can't currently pass us XML objects.
|
||||||
|
node = XML(node);
|
||||||
if (node.length() != 1) {
|
if (node.length() != 1) {
|
||||||
let domnode = doc.createDocumentFragment();
|
let domnode = doc.createDocumentFragment();
|
||||||
for each (let child in node)
|
for each (let child in node)
|
||||||
|
|||||||
@@ -64,7 +64,7 @@
|
|||||||
* :extadd now supports remote URLs as well as local files on Firefox 4.
|
* :extadd now supports remote URLs as well as local files on Firefox 4.
|
||||||
* Added :if/:elseif/:else/:endif conditionals.
|
* Added :if/:elseif/:else/:endif conditionals.
|
||||||
- Added -keyword, -tags, -title to :delbmarks.
|
- Added -keyword, -tags, -title to :delbmarks.
|
||||||
- Added :extupdate command.
|
- Added :extrehash, :exttoggle, :extupdate, and :rehash commands.
|
||||||
- Added :feedkeys command.
|
- Added :feedkeys command.
|
||||||
- Added -sort option to :history.
|
- Added -sort option to :history.
|
||||||
- Added several new options, including -javascript, to :abbrev and :map.
|
- Added several new options, including -javascript, to :abbrev and :map.
|
||||||
|
|||||||
Reference in New Issue
Block a user