Bug 729514 - GCLI needs a way to execute os level commands; r=dcamp
authorJoe Walker <jwalker@mozilla.com>
Tue, 15 May 2012 11:27:18 +0100
changeset 94176 44fe4cd610171c3858120548fadcbbde6e69b3d7
parent 94175 62b89a0b6af180a4cc845a8781cfe4fc61a0f39a
child 94177 64580a473317f82dbe2fb6350640902932232aff
push id9504
push userryanvm@gmail.com
push dateThu, 17 May 2012 00:46:10 +0000
treeherdermozilla-inbound@bd69b36934cb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdcamp
bugs729514
milestone15.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 729514 - GCLI needs a way to execute os level commands; r=dcamp
browser/devtools/webconsole/gcli.jsm
--- a/browser/devtools/webconsole/gcli.jsm
+++ b/browser/devtools/webconsole/gcli.jsm
@@ -763,27 +763,16 @@ var canon = exports;
 
 var util = require('gcli/util');
 var l10n = require('gcli/l10n');
 
 var types = require('gcli/types');
 var Status = require('gcli/types').Status;
 var BooleanType = require('gcli/types/basic').BooleanType;
 
-
-/**
- * A lookup hash of our registered commands
- */
-var commands = {};
-
-/**
- * A sorted list of command names, we regularly want them in order, so pre-sort
- */
-var commandNames = [];
-
 /**
  * Implement the localization algorithm for any documentation objects (i.e.
  * description and manual) in a command.
  * @param data The data assigned to a description or manual property
  * @param onUndefined If data == null, should we return the data untouched or
  * lookup a 'we don't know' key in it's place.
  */
 function lookup(data, onUndefined) {
@@ -1026,16 +1015,31 @@ Object.defineProperty(Parameter.prototyp
   },
   enumerable: true
 });
 
 canon.Parameter = Parameter;
 
 
 /**
+ * A lookup hash of our registered commands
+ */
+var commands = {};
+
+/**
+ * A sorted list of command names, we regularly want them in order, so pre-sort
+ */
+var commandNames = [];
+
+/**
+ * A lookup of the original commandSpecs by command name
+ */
+var commandSpecs = {};
+
+/**
  * Add a command to the canon of known commands.
  * This function is exposed to the outside world (via gcli/index). It is
  * documented in docs/index.md for all the world to see.
  * @param commandSpec The command and its metadata.
  * @return The new command
  */
 canon.addCommand = function addCommand(commandSpec) {
   if (commands[commandSpec.name] != null) {
@@ -1046,31 +1050,34 @@ canon.addCommand = function addCommand(c
     });
   }
 
   var command = new Command(commandSpec);
   commands[commandSpec.name] = command;
   commandNames.push(commandSpec.name);
   commandNames.sort();
 
+  commandSpecs[commandSpec.name] = commandSpec;
+
   canon.onCanonChange();
   return command;
 };
 
 /**
  * Remove an individual command. The opposite of #addCommand().
  * @param commandOrName Either a command name or the command itself.
  */
 canon.removeCommand = function removeCommand(commandOrName) {
   var name = typeof commandOrName === 'string' ?
           commandOrName :
           commandOrName.name;
 
   // See start of canon.addCommand if changing this code
   delete commands[name];
+  delete commandSpecs[name];
   commandNames = commandNames.filter(function(test) {
     return test !== name;
   });
 
   canon.onCanonChange();
 };
 
 /**
@@ -1095,16 +1102,24 @@ canon.getCommands = function getCommands
 /**
  * Get an array containing the names of the registered commands.
  */
 canon.getCommandNames = function getCommandNames() {
   return commandNames.slice(0);
 };
 
 /**
+ * Get access to the stored commandMetaDatas (i.e. before they were made into
+ * instances of Command/Parameters) so we can remote them.
+ */
+canon.getCommandSpecs = function getCommandSpecs() {
+  return commandSpecs;
+};
+
+/**
  * Enable people to be notified of changes to the list of commands
  */
 canon.onCanonChange = util.createEvent('canon.onCanonChange');
 
 /**
  * CommandOutputManager stores the output objects generated by executed
  * commands.
  *
@@ -6693,19 +6708,31 @@ Output.prototype.toDom = function(elemen
   if (typeof HTMLElement !== 'undefined' && output instanceof HTMLElement) {
     node = output;
   }
   else if (output.isView) {
     node = output.toDom(document);
   }
   else {
     if (this.command.returnType === 'terminal') {
-      node = util.createElement(document, 'textarea');
-      node.classList.add('gcli-row-terminal');
-      node.readOnly = true;
+      if (Array.isArray(output)) {
+        node = util.createElement(document, 'div');
+        output.forEach(function() {
+          var child = util.createElement(document, 'textarea');
+          child.classList.add('gcli-row-subterminal');
+          child.readOnly = true;
+
+          node.appendChild(child);
+        });
+      }
+      else {
+        node = util.createElement(document, 'textarea');
+        node.classList.add('gcli-row-terminal');
+        node.readOnly = true;
+      }
     }
     else {
       node = util.createElement(document, 'p');
     }
 
     util.setContents(node, output.toString());
   }