Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shows the help if the command is wrong or empty #83

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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();
}
};