-
-
Save cgranade/24632 to your computer and use it in GitHub Desktop.
Basic first attempt at a command to run programs on the shell.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This is a template command */ | |
CmdUtils.CreateCommand({ | |
name: "shell", | |
icon: "http://example.com/example.png", | |
homepage: "http://sites.google.com/site/cgranade/", | |
author: { name: "Christopher Granade", email: "cgranade@gmail.com"}, | |
license: "GPL", | |
description: "A short description of your command", | |
help: "how to use your command", | |
takes: {"command": noun_arb_text}, | |
preview: function( pblock, input ) { | |
var template = "Will execute <tt>${cmd}</tt>."; | |
pblock.innerHTML = CmdUtils.renderTemplate(template, {"cmd": input.text}); | |
}, | |
execute: function(input) { | |
// For now, must have full path. | |
var cmd = input.text; | |
var proc = Components.classes["@mozilla.org/process/util;1"] | |
.createInstance(Components.interfaces.nsIProcess); | |
var file = Components.classes["@mozilla.org/file/local;1"] | |
.createInstance(Components.interfaces.nsILocalFile); | |
file.initWithPath(cmd); | |
proc.init(file); | |
proc.run(true, null, 0); | |
CmdUtils.setSelection("Ran command successfully."); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment