Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove file listing from console

  • Loading branch information...
commit 4ec185acf2529d446dbdb3840256527b2390b906 1 parent a4051f6
Sergi Mansilla authored
View
18 plugins-client/ext.consolehints/consolehints.js
@@ -149,10 +149,6 @@ module.exports = ext.register("ext/consolehints/consolehints", {
for (var cmd in cmds)
commands.commands[cmd] = cmds[cmd];
};
- c9console.onMessageMethods["internal-autocomplete"] = function(message) {
- var cmds = message.body;
- _self.show(txtConsoleInput, "", cmds.matches, txtConsoleInput.getValue().length - 1);
- };
// Asynchronously retrieve commands that other plugins may have
// registered, hence the (relatively) long timeout.
@@ -300,6 +296,7 @@ module.exports = ext.register("ext/consolehints/consolehints", {
// command `fn2`, calls the functions with the proper array of completions,
// if any.
getCmdCompletion: function(value, fn1, fn2) {
+ console.log("ASDASD", value, fn1, fn2);
var fullCmd = value.match(/(\w+)\s+(.*)$/);
if (fullCmd) {
// If we don't recognize the root command
@@ -309,6 +306,7 @@ module.exports = ext.register("ext/consolehints/consolehints", {
var subCommands = rootCmd.commands;
var filtered;
+ console.log("2", subCommands)
if (subCommands && subCommands["[PATH]"])
filtered = ["[PATH]"];
else if (subCommands)
@@ -333,20 +331,14 @@ module.exports = ext.register("ext/consolehints/consolehints", {
if (cmds.length) {
// This is legacy. Not the best way to determine if a command
// accepts filename inputs
- if (cmds[0] === "[PATH]") {
- ide.send({
- command: "internal-autocomplete",
- argv: [cmd1, cmd2],
- cwd: c9console.getCwd()
- });
- }
- else {
+ if (cmds[0] !== "[PATH]") {
cliValue = cliValue.replace(RE_lastWord, cmds[0]);
}
}
},
function(cmds) {
- if (cmds.length) cliValue = cmds[0];
+ if (cmds.length)
+ cliValue = cmds[0];
}
);
View
111 plugins-server/cloud9.ide.shell/shell.js
@@ -41,76 +41,40 @@ util.inherits(ShellPlugin, Plugin);
this.metadata = {
"commands": {
- "cd" : {
- "hint": "change working directory",
- "commands": {
- "[PATH]": {"hint": "path pointing to a folder. Autocomplete with [TAB]"}
- }
- },
- "ls" : {
- "hint": "list directory contents",
- "commands": {
- "[PATH]": {"hint": "path pointing to a folder. Autocomplete with [TAB]"}
- }
- },
- "rm" : {
- "hint": "remove a file",
- "commands": {
- "[PATH]": {"hint": "path pointing to a folder. Autocomplete with [TAB]"}
- }
- },
- "mv": {
- "hint": "move or rename files or directories",
- "commands": {
- "[PATH]": {"hint": "path pointing to a folder. Autocomplete with [TAB]"}
- }
- },
+ "cd" : { "hint": "change working directory" },
+ "ls" : { "hint": "list directory contents" },
+ "rm" : { "hint": "remove a file" },
+ "mv" : { "hint": "move or rename files or directories" },
"pwd": {"hint": "return working directory name"}
}
};
this.command = function(user, message, client) {
- if (!this["command-" + message.command])
+ var cmdName = "command-" + message.command.toLowerCase();
+ if (!this[cmdName])
return false;
if (message.runner && message.runner !== "shell")
return false;
- this["command-" + message.command.toLowerCase()](message);
+ this[cmdName](message);
return true;
};
- this["command-internal-autocomplete"] = function(message) {
- var argv = [].concat(message.argv);
- var cmd = argv.shift();
- var self = this;
-
- this.getListing(argv.pop(), message.cwd || this.workspaceDir, (cmd == "cd" || cmd == "ls"), function(tail, matches) {
- self.sendResult(0, "internal-autocomplete", {
- matches: matches,
- line : message.line,
- base : tail,
- cursor : message.cursor,
- textbox: message.textbox,
- argv : message.argv
- });
- });
- };
-
this._isDir = function(stat) {
return (
- stat.mime == "inode/directory" ||
- (stat.linkStat && stat.linkStat.mime == "inode/directory")
+ stat.mime === "inode/directory" ||
+ (stat.linkStat && stat.linkStat.mime === "inode/directory")
);
};
this["command-internal-isfile"] = function(message) {
- var file = message.argv.pop();
- var path = message.cwd || this.workspaceDir;
+ var file = message.argv.pop();
+ var path = message.cwd || this.workspaceDir;
var self = this;
- path = Path.normalize(path + "/" + file.replace(/^\//g, ""));
+ path = Path.normalize(path + "/" + file);
if (path.indexOf(this.workspaceDir) === -1) {
this.sendResult();
@@ -171,11 +135,11 @@ util.inherits(ShellPlugin, Plugin);
self.processCount -= 1;
self.sendResult(0, message.command, {
- code : code,
- argv : message.argv,
- err : err,
- out : out,
- extra : message.extra
+ code : code,
+ argv : message.argv,
+ err : err,
+ out : out,
+ extra: message.extra
});
});
};
@@ -185,7 +149,7 @@ util.inherits(ShellPlugin, Plugin);
var path = message.cwd || this.workspaceDir;
var self = this;
- path = Path.normalize(path + "/" + to.replace(/^\//g, ""));
+ path = Path.normalize(path + "/" + to);
if (path.indexOf(this.workspaceDir) === -1)
return this.sendResult();
@@ -212,7 +176,7 @@ util.inherits(ShellPlugin, Plugin);
});
});
};
-
+
this["command-ps"] = function(message) {
var self = this;
this.pm.ps(function(err, procs) {
@@ -228,8 +192,8 @@ util.inherits(ShellPlugin, Plugin);
this["command-kill"] = function(message) {
var self = this;
this.pm.kill(message.pid, function(err) {
- if (!err)
- return;
+ if (!err) return;
+
self.sendResult(0, message.command, {
argv : message.argv,
code : -1,
@@ -240,39 +204,6 @@ util.inherits(ShellPlugin, Plugin);
});
};
- this.getListing = function(tail, path, dirmode, callback) {
- var self = this;
- var matches = [];
- tail = (tail || "")
- .trim()
- .split(/\s+/g)
- .pop();
-
- if (tail.indexOf("/") > -1) {
- path = path.replace(/[\/]+$/, "") + "/" + tail.substr(0, tail.lastIndexOf("/")).replace(/^[\/]+/, "");
- tail = tail.substr(tail.lastIndexOf("/") + 1).replace(/^[\/]+/, "").replace(/[\/]+$/, "");
- }
-
- this.vfs.readdir(this.path, {encoding: null}, function(err, meta) {
- if (err)
- return callback(err);
-
- var stream = meta.stream;
- var nodes = [];
-
- stream.on("data", function(stat) {
- var isDir = self._isDir(stat);
-
- if (stat.name.indexOf(tail) === 0 && (!dirmode || isDir))
- matches.push(stat.name + (isDir ? "/" : ""));
- });
-
- stream.on("end", function() {
- callback(tail, nodes);
- });
- });
- };
-
this.canShutdown = function() {
return this.processCount === 0;
};
Please sign in to comment.
Something went wrong with that request. Please try again.