Skip to content

Commit

Permalink
Shows the help if the command is wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
SamvelRaja committed Sep 26, 2015
1 parent 6790486 commit 84bfd11
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,48 @@ var program = require('commander');
var Watson = require('./watson');
var watson = new Watson();
var version = require('../package.json').version;
var supportedCommands = ['upgrade-qunit-tests', 'convert-prototype-extensions',
'convert-prototype-extensions', 'convert-ember-data-model-lookups',
'convert-ember-data-async-false-relationships', 'convert-resource-router-mapping',
'methodify', 'find-overloaded-cps', 'use-destroy-app-helper'
];

var isSupportedCommands = function(command) {

for (var i = 0; i < supportedCommands.length; i++) {
if (command === supportedCommands[i]) {
return true;
}
}

return false;
};

program
.version(version);

program
.arguments('<cmd>')
.action(function(cmd) {
if (!isSupportedCommands(cmd)) {
console.error('The command is not supported, Use the below supported commands');
program.outputHelp();
process.exit(1);
}
});

program
.command('upgrade-qunit-tests [testsPath]')
.description('Fix QUnit tests to match 2.0 syntax. testsPath defaults to tests/')
.action(function(testsPath){
.action(function(testsPath) {
testsPath = testsPath || 'tests';
watson.transformQUnitTest(testsPath);
});

program
.command('convert-prototype-extensions [appPath]')
.description('Convert computed properties and observers to not use prototype extensions. appPath defaults to app/')
.action(function(appPath){
.action(function(appPath) {
appPath = appPath || 'app';
watson.transformPrototypeExtensions(appPath);
});
Expand Down Expand Up @@ -75,4 +101,7 @@ program

module.exports = function init(args) {
program.parse(args);
if (!process.argv.slice(2).length) {
program.outputHelp();
}
};

0 comments on commit 84bfd11

Please sign in to comment.