diff --git a/plugins/c9.cli.open/open.js b/plugins/c9.cli.open/open.js index 492ac3b7..7ff5cdcc 100755 --- a/plugins/c9.cli.open/open.js +++ b/plugins/c9.cli.open/open.js @@ -31,10 +31,6 @@ define(function(require, exports, module) { description: "Wait until the file(s) are closed", "default": false, "boolean": true - }, - "path" : { - description: "Specify the path that will be opened", - default: false } }, check: function(argv) { diff --git a/plugins/c9.cli/cli.js b/plugins/c9.cli/cli.js index 4a5923fc..91067b16 100755 --- a/plugins/c9.cli/cli.js +++ b/plugins/c9.cli/cli.js @@ -7,6 +7,9 @@ define(function(require, exports, module) { var Plugin = imports.Plugin; var cmd = imports.cli_commands; + var fs = require("fs"); + var resolve = require("path").resolve; + var optimist; /***** Initialization *****/ @@ -21,7 +24,7 @@ define(function(require, exports, module) { var module; var argv; - process.argv.slice(2).some(function(n){ + process.argv.slice(2).some(function(n) { if (!n.match(/^[-\/]/) && n != "node") { module = n; return true; @@ -29,6 +32,18 @@ define(function(require, exports, module) { return false; }); + if (!commands[module] && process.argv.length > 2) { + for (var i = 2; i < process.argv.length; i++) { + if (process.argv[i].charAt(0) == "-") continue; + var path = resolve(process.argv[i]); + if (fs.existsSync(path)) { + process.argv.splice(2, 0, "open"); + module = "open"; + } + break; + } + } + optimist = require('optimist'); if (!module || !commands[module]) {