1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2025-05-10 07:47:07 +01:00
This commit is contained in:
hacksalot
2016-01-17 21:46:58 -05:00
parent e9edc0d15c
commit c9e45d4991
17 changed files with 99 additions and 77 deletions

View File

@ -156,16 +156,17 @@ Error-handling routines for HackMyResume.
ex.data.forEach(function(d){
msg += printf( M2C( this.msgs.invalidFormat.msg, 'bold' ),
ex.theme.name.toUpperCase(), d.format.toUpperCase());
});
}, this);
break;
case HACKMYSTATUS.notOnPath:
msg = printf( M2C(this.msgs.notOnPath, 'bold'), ex.engine);
msg = printf( M2C(this.msgs.notOnPath.msg, 'bold'), ex.engine);
quit = false;
warn = false;
break;
case HACKMYSTATUS.readError:
console.error( printf( M2C(this.msgs.readError.msg, 'red'), ex.file ) );
msg = ex.inner.toString();
warn = false;
break;

View File

@ -1,6 +1,6 @@
/**
Definition of the `main` function.
@module main.js
@module cli/main
@license MIT. See LICENSE.md for details.
*/
@ -32,9 +32,11 @@ Definition of the `main` function.
/**
Main function for HackMyResume
@license MIT. See LICENSE.md for details.
@module main.js
A callable implementation of the HackMyResume CLI. Encapsulates the command
line interface as a single method accepting a parameter array.
@alias module:cli/main.main
@param rawArgs {Array} An array of command-line parameters. Will either be
process.argv (in production) or custom parameters (in test).
*/
var main = module.exports = function( rawArgs ) {
@ -126,22 +128,23 @@ Definition of the `main` function.
/**
Massage command-line args and setup Commander.js.
*/
/** Massage command-line args and setup Commander.js. */
function initialize( ar ) {
logMsg( _title );
var o = initOptions( ar );
// Emit debug prelude if --debug was specified
if( o.debug ) {
_out.log(chalk.cyan('The -d or --debug switch was specified. DEBUG mode engaged.'));
_out.log('');
_out.log(chalk.cyan(PAD(' Platform:',20, null, PAD.RIGHT)) + chalk.cyan.bold( process.platform ));
_out.log(chalk.cyan(PAD(' Node.js:',20, null, PAD.RIGHT)) + chalk.cyan.bold( process.version ));
_out.log(chalk.cyan(PAD(' HackMyResume:',20, null, PAD.RIGHT)) + chalk.cyan.bold('v' + PKG.version ));
_out.log(chalk.cyan(PAD(' FRESCA:',20, null, PAD.RIGHT)) + chalk.cyan.bold( PKG.dependencies.fresca ));
_out.log(chalk.cyan(PAD(' fresh-themes:',20, null, PAD.RIGHT)) + chalk.cyan.bold( PKG.dependencies['fresh-themes'] ));
_out.log(chalk.cyan(PAD(' Platform:',25, null, PAD.RIGHT)) + chalk.cyan.bold( process.platform === 'win32' ? 'windows' : process.platform ));
_out.log(chalk.cyan(PAD(' Node.js:',25, null, PAD.RIGHT)) + chalk.cyan.bold( process.version ));
_out.log(chalk.cyan(PAD(' HackMyResume:',25, null, PAD.RIGHT)) + chalk.cyan.bold('v' + PKG.version ));
_out.log(chalk.cyan(PAD(' FRESCA:',25, null, PAD.RIGHT)) + chalk.cyan.bold( PKG.dependencies.fresca ));
_out.log(chalk.cyan(PAD(' fresh-themes:',25, null, PAD.RIGHT)) + chalk.cyan.bold( PKG.dependencies['fresh-themes'] ));
_out.log(chalk.cyan(PAD(' fresh-jrs-converter:',25, null, PAD.RIGHT)) + chalk.cyan.bold( PKG.dependencies['fresh-jrs-converter'] ));
_out.log('');
}
@ -172,14 +175,12 @@ Definition of the `main` function.
/**
Init options prior to setting up command infrastructure.
*/
/** Init options prior to setting up command infrastructure. */
function initOptions( ar ) {
var oVerb, verb = '', args = ar.slice(), cleanArgs = args.slice(2), oJSON;
if( cleanArgs.length ) {
// Support case-insensitive sub-commands (build, generate, validate, etc.)..
// Support case-insensitive sub-commands (build, generate, validate, etc)
var vidx = _.findIndex( cleanArgs, function(v){ return v[0] !== '-'; });
if( vidx !== -1 ) {
oVerb = cleanArgs[ vidx ];
@ -223,9 +224,7 @@ Definition of the `main` function.
/**
Invoke a HackMyResume verb.
*/
/** Invoke a HackMyResume verb. */
function execute( src, dst, opts, log ) {
loadOptions.call( this, opts, this.parent.jsonArgs );
@ -271,7 +270,8 @@ Definition of the `main` function.
if( o.debug ) {
logMsg(chalk.cyan('OPTIONS:') + '\n');
_.each(o, function(val, key) {
logMsg(chalk.cyan(' %s') + chalk.cyan.bold(' %s'), PAD(key,17,null,PAD.RIGHT), val);
logMsg(chalk.cyan(' %s') + chalk.cyan.bold(' %s'),
PAD(key,17,null,PAD.RIGHT), val);
});
logMsg('');
}
@ -282,9 +282,7 @@ Definition of the `main` function.
/**
Split multiple command-line filenames by the 'TO' keyword
*/
/** Split multiple command-line filenames by the 'TO' keyword */
function splitSrcDest() {
var params = this.parent.args.filter(function(j) { return String.is(j); });
@ -314,9 +312,7 @@ Definition of the `main` function.
/**
Simple logging placeholder.
*/
/** Simple logging placeholder. */
function logMsg() {
_opts.silent || console.log.apply( console.log, arguments );
}

View File

@ -1,10 +1,12 @@
events:
begin:
msg: Invoking **%s** command.
beforeCreate:
msg: Creating new **%s** resume: **%s**
beforeRead:
msg: Reading resume: **%s**
afterRead:
msg: Reading **%s** resume: **%s**
beforeTheme:
msg: Verifying theme: **%s**
msg: Verifying **%s** theme.
afterTheme:
msg: Verifying outputs: ???
beforeMerge:
@ -72,5 +74,7 @@ errors:
msg: The **%s** theme doesn't support the **%s** format.
notOnPath:
msg: %s wasn't found on your system path or is inaccessible. PDF not generated.
readError:
msg: Reading **???** resume: **%s**
parseError:
msg: Invalid or corrupt JSON on line %s column %s.

View File

@ -22,7 +22,8 @@ Output routines for HackMyResume.
, HANDLEBARS = require('handlebars')
, YAML = require('yamljs')
, printf = require('printf')
, pad = require('string-padding');
, pad = require('string-padding')
, dbgStyle = 'cyan';
@ -58,8 +59,12 @@ Output routines for HackMyResume.
switch( evt.sub ) {
case HME.begin:
this.opts.debug &&
L( M2C( this.msgs.begin.msg, dbgStyle), evt.cmd.toUpperCase() );
break;
case HME.error:
//L('ERROR occured');
break;
case HME.beforeCreate:
@ -67,9 +72,6 @@ Output routines for HackMyResume.
break;
case HME.beforeRead:
L(
M2C( this.msgs.beforeRead.msg, 'cyan' ), evt.file
);
break;
case HME.afterRead:
@ -77,12 +79,16 @@ Output routines for HackMyResume.
case HME.beforeTheme:
this.opts.debug &&
L( M2C( this.msgs.beforeTheme.msg, 'cyan'), evt.theme.toUpperCase() );
L( M2C( this.msgs.beforeTheme.msg, dbgStyle), evt.theme.toUpperCase() );
break;
case HME.afterParse:
L( M2C( this.msgs.afterRead.msg, 'green' ), evt.fmt.toUpperCase(), evt.file );
break;
case HME.afterTheme:
this.theme = evt.theme;
this.opts.debug && L( M2C(this.msgs.beforeTheme.msg, 'cyan'), evt.theme );
// this.opts.debug && L( M2C(this.msgs.beforeTheme.msg, 'green'), evt.theme );
break;
case HME.beforeMerge:
@ -99,7 +105,7 @@ Output routines for HackMyResume.
case HME.afterMerge:
var numFormats = Object.keys( this.theme.formats ).length;
L( M2C(this.msgs.afterMerge.msg, 'yellow'),
L( M2C(this.msgs.afterMerge.msg, 'green'),
this.theme.name.toUpperCase(),
numFormats, ( numFormats === 1 ? '' : 's') );
break;
@ -180,7 +186,6 @@ Output routines for HackMyResume.
err.message) );
}, this);
}
break;
case HME.beforePeek: