Skip to content

Commit

Permalink
Feat: Added default fallback for CLI (#271)
Browse files Browse the repository at this point in the history
  • Loading branch information
adampash authored Aug 8, 2016
1 parent 4ff3f81 commit 14a9cea
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions bin/lux
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const PROJECT_REQUIRED = [

const cli = require('commander');
const path = require('path');
const { EOL } = require('os');
const { red, green } = require('chalk');

function inLuxProject() {
if (PWD.indexOf(path.join('lux', 'test', 'test-app')) >= 0) {
Expand All @@ -32,6 +34,11 @@ function inLuxProject() {
}
}

function commandNotFound(cmd) {
console.log(`${EOL} ${red(cmd)} is not a valid command${EOL}`);
console.log(` Use ${green('lux --help')} for a full list of commands${EOL}`);
}

function exec(cmd, ...args) {
let handler;

Expand Down Expand Up @@ -232,6 +239,11 @@ cli
.catch(rescue);
});

cli
.on('*', (cmd) => {
commandNotFound(cmd)
});

cli.parse(process.argv);

if (!cli.args.length) {
Expand Down

0 comments on commit 14a9cea

Please sign in to comment.