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

Finish Commander.js integration.

This commit is contained in:
hacksalot 2016-01-03 03:18:56 -05:00
parent 655ecebaa5
commit 8d7cf32988
5 changed files with 56 additions and 49 deletions

View File

@ -208,6 +208,14 @@ Definition of the FRESHResume class.
return this.parseJSON( JSON.parse( stringData ), opts ); return this.parseJSON( JSON.parse( stringData ), opts );
}; };
/**
Return internal metadata. Create if it doesn't exist.
*/
FreshResume.prototype.imp = function() {
this.imp = (this.imp || { });
return this.imp;
};
/** /**
Return a unique list of all keywords across all skills. Return a unique list of all keywords across all skills.
*/ */

View File

@ -136,6 +136,16 @@ Definition of the JRSResume class.
return flatSkills; return flatSkills;
}; };
/**
Return internal metadata. Create if it doesn't exist.
JSON Resume v0.0.0 doesn't allow additional properties at the root level,
so tuck this into the .basic sub-object.
*/
JRSResume.prototype.imp = function() {
this.basics = this.basics || { imp: { } };
return this.basics;
};
/** /**
Reset the sheet to an empty state. Reset the sheet to an empty state.
*/ */

View File

@ -75,6 +75,7 @@ Definition of the ResumeFactory class.
if( objectify ) { if( objectify ) {
var ResumeClass = require('../core/' + (toFormat || orgFormat) + '-resume'); var ResumeClass = require('../core/' + (toFormat || orgFormat) + '-resume');
rez = new ResumeClass().parseJSON( json ); rez = new ResumeClass().parseJSON( json );
rez.imp().file = src;
} }
return { return {

View File

@ -1,5 +1,7 @@
#! /usr/bin/env node #! /usr/bin/env node
/** /**
Command-line interface (CLI) for HackMyResume. Command-line interface (CLI) for HackMyResume.
@license MIT. Copyright (c) 2015 hacksalot (https://github.com/hacksalot) @license MIT. Copyright (c) 2015 hacksalot (https://github.com/hacksalot)
@ -90,8 +92,9 @@ function main() {
.alias('generate') .alias('generate')
//.arguments('<sources> TO [targets]') //.arguments('<sources> TO [targets]')
//.usage('...') //.usage('...')
.option('-t --theme <theme>', 'Theme name or path') .option('-t --theme <theme>', 'Theme name or path', 'modern')
.option('-p --prettify', 'Preffity HTML output.') .option('-p --prettify', 'Preffity HTML output', true)
.option('-c --css <option>', 'CSS linking / embedding', 'embed')
.description('Generate resume to multiple formats') .description('Generate resume to multiple formats')
.action(function( sources, targets, options ) { .action(function( sources, targets, options ) {
var x = splitSrcDest.call( this ); var x = splitSrcDest.call( this );
@ -114,35 +117,6 @@ function main() {
/**
Split multiple command-line filenames by the 'TO' keyword
*/
function splitSrcDest() {
var params = this.parent.args.filter(function(j) { return String.is(j); });
if( params.length === 0 )
throw { fluenterror: HACKMYSTATUS.resumeNotFound };
// Find the TO keyword, if any
var splitAt = _.findIndex( params, function(p) {
return p.toLowerCase() === 'to';
});
// TO can't be the last keyword
if( splitAt === params.length - 1 && splitAt !== -1 ) {
logMsg(chalk.yellow('Please ') +
chalk.yellow.bold('specify an output file') +
chalk.yellow(' for this operation or ') +
chalk.yellow.bold('omit the TO keyword') +
chalk.yellow('.') );
return;
}
return {
src: params.slice(0, splitAt === -1 ? undefined : splitAt ),
dst: splitAt === -1 ? [] : params.slice( splitAt + 1 )
};
}
/** /**
@ -183,26 +157,40 @@ function initialize() {
/** /**
Simple logging placeholder. Split multiple command-line filenames by the 'TO' keyword
*/ */
function logMsg( msg ) { function splitSrcDest() {
opts.silent || console.log( msg );
var params = this.parent.args.filter(function(j) { return String.is(j); });
if( params.length === 0 )
throw { fluenterror: HACKMYSTATUS.resumeNotFound };
// Find the TO keyword, if any
var splitAt = _.findIndex( params, function(p) {
return p.toLowerCase() === 'to';
});
// TO can't be the last keyword
if( splitAt === params.length - 1 && splitAt !== -1 ) {
logMsg(chalk.yellow('Please ') +
chalk.yellow.bold('specify an output file') +
chalk.yellow(' for this operation or ') +
chalk.yellow.bold('omit the TO keyword') +
chalk.yellow('.') );
return;
}
return {
src: params.slice(0, splitAt === -1 ? undefined : splitAt ),
dst: splitAt === -1 ? [] : params.slice( splitAt + 1 )
};
} }
/** /**
Fetch options from command line arguments. Simple logging placeholder.
*/ */
function getOpts( args ) { function logMsg( msg ) {
var noPretty = args.nopretty || args.n; opts.silent || console.log( msg );
noPretty = noPretty && (noPretty === true || noPretty === 'true');
return {
theme: args.t || 'modern',
format: args.f || 'FRESH',
prettify: !noPretty,
silent: args.s || args.silent,
css: args.css || 'embed',
help: args.help || undefined
};
} }

View File

@ -74,8 +74,8 @@ Implementation of the 'generate' verb for HackMyResume.
var msg = ''; var msg = '';
rez = _.reduceRight( sheets, function( a, b, idx ) { rez = _.reduceRight( sheets, function( a, b, idx ) {
msg += ((idx == sheets.length - 2) ? msg += ((idx == sheets.length - 2) ?
chalk.cyan('Merging ') + chalk.cyan.bold(a.file) : '') + chalk.cyan('Merging ') + chalk.cyan.bold(a.imp().file) : '') +
chalk.cyan(' onto ') + chalk.cyan.bold(b.file); chalk.cyan(' onto ') + chalk.cyan.bold(b.imp().file);
return extend( true, b, a ); return extend( true, b, a );
}); });
msg && _log(msg); msg && _log(msg);