1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-11-23 00:40:10 +00:00

Support --help option.

Support standard syntax for the HELP command.
This commit is contained in:
hacksalot 2016-01-01 14:38:00 -05:00
parent 84ad6cf356
commit bb28e5aa8e

View File

@ -34,18 +34,6 @@ catch( ex ) {
function main() { function main() {
// Colorize
// COLORS.setTheme({
// title: ['white','bold'],
// info: process.platform === 'win32' ? 'gray' : ['white','dim'],
// infoBold: ['white','dim'],
// warn: 'yellow',
// error: 'red',
// guide: 'yellow',
// status: 'gray',//['white','dim'],
// useful: 'green',
// });
// Setup // Setup
if( process.argv.length <= 2 ) { throw { fluenterror: 4 }; } if( process.argv.length <= 2 ) { throw { fluenterror: 4 }; }
var a = ARGS( process.argv.slice(2) ); var a = ARGS( process.argv.slice(2) );
@ -54,7 +42,7 @@ function main() {
// Get the action to be performed // Get the action to be performed
var params = a._.map( function(p){ return p.toLowerCase().trim(); }); var params = a._.map( function(p){ return p.toLowerCase().trim(); });
var verb = params[0]; var verb = opts.help ? 'help' : params[0];
if( !FCMD.verbs[ verb ] && !FCMD.alias[ verb ] ) { if( !FCMD.verbs[ verb ] && !FCMD.alias[ verb ] ) {
logMsg(chalk.yellow('Invalid command: "') + chalk.yellow.bold(verb) + chalk.yellow('"')); logMsg(chalk.yellow('Invalid command: "') + chalk.yellow.bold(verb) + chalk.yellow('"'));
return; return;
@ -62,11 +50,11 @@ function main() {
// Find the TO keyword, if any // Find the TO keyword, if any
var splitAt = _.indexOf( params, 'to' ); var splitAt = _.indexOf( params, 'to' );
if( splitAt === a._.length - 1 ) { if( splitAt === a._.length - 1 && splitAt !== -1 ) {
// 'TO' cannot be the last argument // 'TO' cannot be the last argument
logMsg('Please '.warn + 'specify an output file'.warn.bold + logMsg(chalk.yellow('Please ') + chalk.yellow.bold('specify an output file') +
' for this operation or '.warn + 'omit the TO keyword'.warn.bold + chalk.yellow(' for this operation or ') + chalk.yellow.bold('omit the TO keyword') +
'.'.warn ); chalk.yellow('.') );
return; return;
} }
@ -92,6 +80,7 @@ function getOpts( args ) {
format: args.f || 'FRESH', format: args.f || 'FRESH',
prettify: !noPretty, prettify: !noPretty,
silent: args.s || args.silent, silent: args.s || args.silent,
css: args.css || 'embed' css: args.css || 'embed',
help: args.help || undefined
}; };
} }