Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
cleanup how the cli is invoked a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Isao Yagi committed Mar 13, 2013
1 parent 2ebf1d5 commit 6d1b304
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 3 additions & 5 deletions bin/mojito
Expand Up @@ -4,9 +4,7 @@
* Copyrights licensed under the New BSD License.
* See the accompanying LICENSE file for terms.
*/
var cli,
resolve = require('path').resolve,
mojito = require(resolve(__dirname, '../lib/mojito'));
var resolve = require('path').resolve;
cli = require(resolve(__dirname, '../lib/management/cli'));

cli = mojito.include('management/cli');
cli.run();
cli.run(process.argv.slice(2));
8 changes: 3 additions & 5 deletions lib/management/cli.js
Expand Up @@ -140,18 +140,16 @@
* the command module's run method will be invoked. The command module's
* exported options are used to assist in parsing the command line.
*/
CLI.run = function() {
var args = process.argv.slice(2),
commandName = (args.length === 0 ? 'help' : args.shift()),
CLI.run = function(args) {
var commandName = args.shift() || 'help',
command,
argInfo;

try {
command = require('mojito-cli-cmd-' + commandName);
} catch (e) {
try {
command = require(libpath.join(__dirname, '../app/commands/',
commandName));
command = require(libpath.join('../app/commands/', commandName));
} catch (e2) {
utils.error('Error loading command: ' + command + ' ' + e2.message,
'mojito <command> [<params>] [<options>]');
Expand Down

0 comments on commit 6d1b304

Please sign in to comment.