1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2025-07-09 11:41:07 +01:00
This commit is contained in:
devlinjd
2015-11-21 10:33:16 -05:00
parent cbddb4b3aa
commit 992069b22d
4 changed files with 30 additions and 15 deletions

View File

@ -9,7 +9,8 @@ var ARGS = require( 'minimist' )
, FCMD = require( './fluentcmd')
, PKG = require('../package.json')
, opts = { }
, title = ('*** FluentCV v' + PKG.version + ' ***').white.bold;
, title = ('*** FluentCV v' + PKG.version + ' ***').white.bold
, _ = require('underscore');
@ -30,16 +31,28 @@ function main() {
logMsg( title );
// Get the action to be performed
var verb = a._[0].toLowerCase().trim();
var params = a._.map( function(p){ return p.toLowerCase().trim(); });
var verb = params[0];
if( !FCMD.verbs[ verb ] ) {
logMsg('Invalid command: "'.yellow + verb.yellow.bold + '"'.yellow);
return;
}
// Get source and dest params
var splitAt = _.indexOf( params, 'to' );
if( splitAt === a._.length - 1 ) {
// 'TO' cannot be the last argument
logMsg('Please '.gray + 'specify an output file' + ' for this operation or '.gray + 'omit the TO keyword' + '.'.gray);
return;
}
var src = a._.slice(1, splitAt === -1 ? undefined : splitAt );
var dst = splitAt === -1 ? [] : a._.slice( splitAt + 1 );
// Preload our params array
var dst = (a.o && ((typeof a.o === 'string' && [ a.o ]) || a.o)) || [];
dst = (dst === true) ? [] : dst; // Handle -o with missing output file
var parms = [ a._.slice(1) || [], dst, opts, logMsg ];
//var dst = (a.o && ((typeof a.o === 'string' && [ a.o ]) || a.o)) || [];
//dst = (dst === true) ? [] : dst; // Handle -o with missing output file
var parms = [ src, dst, opts, logMsg ];
// Invoke the action
FCMD.verbs[ verb ].apply( null, parms );
@ -66,12 +79,14 @@ function handleError( ex ) {
switch( ex.fluenterror ) { // TODO: Remove magic numbers
case 1: msg = "The specified theme couldn't be found: " + ex.data; break;
case 2: msg = "Couldn't copy CSS file to destination folder"; break;
case 3: msg = "Please specify a valid SOURCE resume in FRESH or JSON Resume format.".gray; break;
case 4: msg = title + "\nPlease specify a valid command (".gray +
case 3: msg = 'Please '.gray + 'specify a valid input resume' + ' in '.gray + 'FRESH' + ' or '.gray + 'JSON Resume' + ' format.'.gray; break;
case 4: msg = title + "\nPlease specify a command (".gray +
Object.keys( FCMD.verbs ).map( function(v, idx, ar) {
return (idx === ar.length - 1 ? 'or '.gray : '')
+ v.toUpperCase().white.bold;
+ v.toUpperCase();
}).join(', ') + ")";
break;
case 5: msg = "Please specify the name of the TARGET file to convert to.".gray;
};
exitCode = ex.fluenterror;
}
@ -82,7 +97,7 @@ function handleError( ex ) {
var idx = msg.indexOf('Error: ');
var trimmed = idx === -1 ? msg : msg.substring( idx + 7 );
if( !ex.fluenterror || ex.fluenterror !== 4 && ex.fluenterror !== 3 )
if( !ex.fluenterror || ex.fluenterror < 3 )
console.log( ('ERROR: ' + trimmed.toString()).red.bold );
else
console.log( trimmed.toString() );