1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-11-22 16:30:11 +00:00

Refactor status codes.

This commit is contained in:
hacksalot 2015-12-29 05:09:05 -05:00
parent e65c0e128e
commit 13430bcad5
3 changed files with 62 additions and 18 deletions

21
src/core/status-codes.js Normal file
View File

@ -0,0 +1,21 @@
/**
Status codes for HackMyResume.
@module status-codes.js
*/
(function(){
module.exports = {
success: 0,
themeNotFound: 1,
copyCss: 2,
resumeNotFound: 3,
missingCommand: 4,
invalidCommand: 5,
resumeNotFoundAlt: 6,
inputOutputParity: 7,
createNameMissing: 8,
wkhtmltopdf: 9
};
}());

View File

@ -26,14 +26,7 @@ Definition of the BaseGenerator class.
/** /**
Status codes. Status codes.
*/ */
codes: { codes: require('../core/status-codes'),
success: 0,
themeNotFound: 1,
copyCss: 2,
resumeNotFound: 3,
missingCommand: 4,
invalidCommand: 5
},
/** /**
Generator options. Generator options.

View File

@ -12,6 +12,7 @@ var ARGS = require( 'minimist' )
, COLORS = require('colors') , COLORS = require('colors')
, FS = require('fs') , FS = require('fs')
, PATH = require('path') , PATH = require('path')
, HACKMYSTATUS = require('./core/status-codes')
, opts = { } , opts = { }
, title = ('\n*** HackMyResume v' + PKG.version + ' ***').bold.white , title = ('\n*** HackMyResume v' + PKG.version + ' ***').bold.white
, _ = require('underscore'); , _ = require('underscore');
@ -99,20 +100,49 @@ function handleError( ex ) {
if( ex.fluenterror ){ if( ex.fluenterror ){
switch( ex.fluenterror ) { // TODO: Remove magic numbers 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 HACKMYSTATUS.themeNotFound:
case 3: msg = 'Please '.guide + 'specify a valid input resume'.guide.bold + ' in FRESH or JSON Resume format.'.guide; break; msg = "The specified theme couldn't be found: " + ex.data;
case 4: msg = title + "\nPlease ".guide + "specify a command".guide.bold + " (".guide + break;
case HACKMYSTATUS.copyCSS:
msg = "Couldn't copy CSS file to destination folder";
break;
case HACKMYSTATUS.resumeNotFound:
msg = 'Please '.guide + 'specify a valid input resume'.guide.bold +
' in FRESH or JSON Resume format.'.guide;
break;
case HACKMYSTATUS.missingCommand:
msg = title + "\nPlease ".guide + "specify a command".guide.bold + " (".guide +
Object.keys( FCMD.verbs ).map( function(v, idx, ar) { Object.keys( FCMD.verbs ).map( function(v, idx, ar) {
return (idx === ar.length - 1 ? 'or '.guide : '') + return (idx === ar.length - 1 ? 'or '.guide : '') +
v.toUpperCase().guide; v.toUpperCase().guide;
}).join(', '.guide) + ").\n\n".guide + FS.readFileSync( PATH.join(__dirname, 'use.txt'), 'utf8' ).info.bold; }).join(', '.guide) + ").\n\n".guide +
FS.readFileSync( PATH.join(__dirname, 'use.txt'), 'utf8' ).info.bold;
break; break;
//case 4: msg = title + '\n' + ; break;
case 5: msg = 'Please '.guide + 'specify the output resume file'.guide.bold + ' that should be created.'.guide; break; case HACKMYSTATUS.invalidCommand:
case 6: msg = 'Please '.guide + 'specify a valid input resume'.guide.bold + ' in either FRESH or JSON Resume format.'.guide; break; msg = 'Please '.guide + 'specify the output resume file'.guide.bold +
case 7: msg = 'Please '.guide + 'specify an output file name'.guide.bold + ' for every input file you wish to convert.'.guide; break; ' that should be created.'.guide;
case 8: msg = 'Please '.guide + 'specify the filename of the resume'.guide.bold + ' to create.'.guide; break; break;
case HACKMYSTATUS.resumeNotFoundAlt:
msg = 'Please '.guide + 'specify a valid input resume'.guide.bold +
' in either FRESH or JSON Resume format.'.guide;
break;
case HACKMYSTATUS.inputOutputParity:
msg = 'Please '.guide + 'specify an output file name'.guide.bold +
' for every input file you wish to convert.'.guide;
break;
case HACKMYSTATUS.createNameMissing:
msg = 'Please '.guide + 'specify the filename of the resume'.guide.bold +
' to create.'.guide;
break;
} }
exitCode = ex.fluenterror; exitCode = ex.fluenterror;