define(function(l, m) {
var i = l("pilot/typecheck"), e = l("pilot/canon"), j = {plainPrefix:'
Welcome to Skywriter - Code in the Cloud
',
plainSuffix:'For more information, see the Skywriter Wiki.'}, n = {name:"help", params:[{name:"search", type:"text", description:"Search string to narrow the output.", defaultValue:null}], description:"Get help on the available commands.", exec:function(b, c, g) {
b = [];
var a = e.getCommand(c.search);
if(a && a.exec) {
b.push(a.description ? a.description : "No description for " + c.search)
}else {
var k = false;
!c.search && j.plainPrefix && b.push(j.plainPrefix);
if(a) {
b.push("Sub-Commands of " + a.name + "
");
b.push("" + a.description + "
")
}else {
if(c.search) {
if(c.search == "hidden") {
c.search = "";
k = true
}b.push("Commands starting with '" + c.search + "':
")
}else {
b.push("Available Commands:
")
}
}var f = e.getCommandNames();
f.sort();
b.push("");
for(var d = 0;d < f.length;d++) {
a = e.getCommand(f[d]);
if(!(!k && a.hidden)) {
if(a.description !== undefined) {
if(!(c.search && a.name.indexOf(c.search) !== 0)) {
if(!(!c.search && a.name.indexOf(" ") != -1)) {
if(!(a && a.name == c.search)) {
b.push("");
b.push('| ' + a.name + " | ");
b.push("" + a.description + " | ");
b.push("
")
}
}
}
}
}
}b.push("
");
!c.search && j.plainSuffix && b.push(j.plainSuffix)
}g.done(b.join(""))
}}, p = {name:"eval", params:[{name:"javascript", type:"text", description:"The JavaScript to evaluate"}], description:"evals given js code and show the result", hidden:true, exec:function(b, c, g) {
var a;
b = c.javascript;
try {
a = eval(b)
}catch(k) {
a = "Error: " + k.message + ""
}var f = c = "", d;
if(i.isFunction(a)) {
c = (a + "").replace(/\n/g, "
").replace(/ /g, " ");
f = "function"
}else {
if(i.isObject(a)) {
f = Array.isArray(a) ? "array" : "object";
var h = [], o;
for(d in a) {
if(a.hasOwnProperty(d)) {
o = i.isFunction(a[d]) ? "[function]" : i.isObject(a[d]) ? "[object]" : a[d];
h.push({name:d, value:o})
}
}h.sort(function(s, t) {
return s.name.toLowerCase() < t.name.toLowerCase() ? -1 : 1
});
for(d = 0;d < h.length;d++) {
c += "" + h[d].name + ": " + h[d].value + "
"
}
}else {
c = a;
f = typeof a
}
}g.done("Result for eval '" + b + "' (type: " + f + "):
" + c)
}}, r = {name:"skywriter", hidden:true, exec:function(b, c, g) {
b = Math.floor(Math.random() * q.length);
g.done("Skywriter " + q[b])
}}, q = ["really wants you to trick it out in some way.", "is your Web editor.", "would love to be like Emacs on the Web.", "is written on the Web platform, so you can tweak it."];
e = l("pilot/canon");
m.startup = function() {
e.addCommand(n);
e.addCommand(p);
e.addCommand(r)
};
m.shutdown = function() {
e.removeCommand(n);
e.removeCommand(p);
e.removeCommand(r)
}
});