1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-12-23 13:47:22 +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 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.
*/

View File

@ -136,6 +136,16 @@ Definition of the JRSResume class.
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.
*/

View File

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

View File

@ -1,5 +1,7 @@
#! /usr/bin/env node
/**
Command-line interface (CLI) for HackMyResume.
@license MIT. Copyright (c) 2015 hacksalot (https://github.com/hacksalot)
@ -90,12 +92,13 @@ function main() {
.alias('generate')
//.arguments('<sources> TO [targets]')
//.usage('...')
.option('-t --theme <theme>', 'Theme name or path')
.option('-p --prettify', 'Preffity HTML output.')
.option('-t --theme <theme>', 'Theme name or path', 'modern')
.option('-p --prettify', 'Preffity HTML output', true)
.option('-c --css <option>', 'CSS linking / embedding', 'embed')
.description('Generate resume to multiple formats')
.action(function( sources, targets, options ) {
var x = splitSrcDest.call( this );
FCMD.verbs[ this.name() ].call( null, x.src, x.dst, this.opts(), logMsg);
FCMD.verbs[ this.name() ].call( null, x.src, x.dst, this.opts(), logMsg );
});
// program.on('--help', function(){
@ -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 ) {
opts.silent || console.log( msg );
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 )
};
}
/**
Fetch options from command line arguments.
Simple logging placeholder.
*/
function getOpts( args ) {
var noPretty = args.nopretty || args.n;
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
};
function logMsg( msg ) {
opts.silent || console.log( msg );
}

View File

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