From 6e4263e58c53db1a226c699baefec97b4d138859 Mon Sep 17 00:00:00 2001 From: devlinjd Date: Sat, 10 Oct 2015 15:39:13 -0400 Subject: [PATCH 1/7] Change default theme to "modern". --- README.md | 12 ++++++------ src/fluentcmd.js | 6 +++--- src/index.js | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 1bf1b24..cabcfb9 100644 --- a/README.md +++ b/README.md @@ -38,13 +38,13 @@ Where `[inputs]` is one or more .json resume files, `[outputs]` is one or more d ```bash # Generate all resume formats (HTML, PDF, DOC, TXT) -fluentcmd resume.json resume.all -t informatic +fluentcmd resume.json resume.all -t modern # Generate a specific resume format -fluentcmd resume.json resume.html -t informatic -fluentcmd resume.json resume.txt -t informatic -fluentcmd resume.json resume.pdf -t informatic -fluentcmd resume.json resume.doc -t informatic +fluentcmd resume.json resume.html -t modern +fluentcmd resume.json resume.txt -t modern +fluentcmd resume.json resume.pdf -t modern +fluentcmd resume.json resume.doc -t modern ``` You should see something to the effect of: @@ -94,7 +94,7 @@ fluentcmd me.json out1.doc out1.pdf foo.txt You can also omit the output file(s) and/or theme completely: ```bash -# Equivalent to "fluentcmd resume.json resume.all -t informatic" +# Equivalent to "fluentcmd resume.json resume.all -t modern" fluentcmd resume.json ``` diff --git a/src/fluentcmd.js b/src/fluentcmd.js index ce281cc..e1d8581 100644 --- a/src/fluentcmd.js +++ b/src/fluentcmd.js @@ -19,14 +19,14 @@ module.exports = function () { generate 0..N resumes in the desired formats. @param src Path to the source JSON resume file: "rez/resume.json". @param dst An array of paths to the target resume file(s). - @param theme Friendly name of the resume theme. Defaults to "informatic". + @param theme Friendly name of the resume theme. Defaults to "modern". @param logger Optional logging override. */ function gen( src, dst, theme, logger, errHandler ) { _log = logger || console.log; _err = errHandler || error; - _opts.theme = (theme && theme.toLowerCase().trim()) || 'informatic'; + _opts.theme = (theme && theme.toLowerCase().trim()) || 'modern'; // Load input resumes... if(!src || !src.length) { throw { fluenterror: 3 }; } @@ -105,7 +105,7 @@ module.exports = function () { Default options. */ var _opts = { - theme: 'informatic', + theme: 'modern', } /** diff --git a/src/index.js b/src/index.js index fa9eea2..f8d97d4 100644 --- a/src/index.js +++ b/src/index.js @@ -15,7 +15,7 @@ try { var args = ARGS( process.argv.slice(2) ); var src = args._.filter( function( a ) { return a.match(/\.json$/); }); var dst = args._.filter( function( a ) { return !a.match(/\.json$/); }); - FCMD.generate( src, dst, args.t || 'informatic' ); + FCMD.generate( src, dst, args.t || 'modern' ); process.platform !== 'win32' && console.log('\n'); } catch( ex ) { From 189f37b6a183c6a611fc745ebad894ef3e2c7774 Mon Sep 17 00:00:00 2001 From: devlinjd Date: Sat, 10 Oct 2015 17:49:29 -0400 Subject: [PATCH 2/7] Add Markdown format support. --- src/fluentcmd.js | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/fluentcmd.js b/src/fluentcmd.js index e1d8581..dd4f0ac 100644 --- a/src/fluentcmd.js +++ b/src/fluentcmd.js @@ -49,7 +49,8 @@ module.exports = function () { ( (dst && dst.length && dst) || ['resume.all'] ).forEach( function(t) { var to = path.resolve(t), pa = path.parse(to), fmat = pa.ext || '.all'; targets.push.apply(targets, fmat === '.all' ? - _fmts.map(function(z){ return to.replace(/all$/g,z.name); }) : [to]); + _fmts.map(function(z){ return { file: to.replace(/all$/g,z.ext), fmt: z } }) + : [{ file: to, fmt: z }]); }); // Run the transformation! @@ -64,19 +65,12 @@ module.exports = function () { @param f Full path to the destination resume to generate, for example, "/foo/bar/resume.pdf" or "c:\foo\bar\resume.txt". */ - function single( f ) { + function single( fi ) { try { - // Get the output file type (pdf, html, txt, etc) - var fType = path.extname( f ).trim().toLowerCase().substr(1); - var fName = path.basename( f, '.' + fType ); - - // Get the format object (if any) corresponding to that type, and assemble - // the final output file path for the generated resume. - var fObj = _fmts.filter( function(_f) { return _f.name === fType; } )[0]; + var f = fi.file, fType = fi.fmt.ext, fName = path.basename( f, '.' + fType ); + var fObj = _fmts.filter( function(_f) { return _f.ext === fType; } )[0]; var fOut = path.join( f.substring( 0, f.lastIndexOf('.') + 1 ) + fObj.ext ); - - // Generate! - _log( 'Generating ' + fType.toUpperCase() + ' resume: ' + path.relative(process.cwd(), f) ); + _log( 'Generating ' + fi.fmt.name.toUpperCase() + ' resume: ' + path.relative(process.cwd(), f ) ); return fObj.gen.generate( rez, fOut, _opts.theme ); } catch( ex ) { @@ -98,7 +92,8 @@ module.exports = function () { { name: 'html', ext: 'html', gen: new FLUENT.HtmlGenerator() }, { name: 'txt', ext: 'txt', gen: new FLUENT.TextGenerator() }, { name: 'doc', ext: 'doc', fmt: 'xml', gen: new FLUENT.WordGenerator() }, - { name: 'pdf', ext: 'pdf', fmt: 'html', is: false, gen: new FLUENT.HtmlPdfGenerator() } + { name: 'pdf', ext: 'pdf', fmt: 'html', is: false, gen: new FLUENT.HtmlPdfGenerator() }, + { name: 'markdown', ext: 'md', fmt: 'txt', gen: new FLUENT.MarkdownGenerator() } ]; /** From a2b482f60bbc8a0236446ae02c06a491e3fb6275 Mon Sep 17 00:00:00 2001 From: devlinjd Date: Sat, 10 Oct 2015 18:34:36 -0400 Subject: [PATCH 3/7] Update README. --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cabcfb9..0e166be 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ fluentcmd resume.json resume.doc -t modern You should see something to the effect of: ``` -*** FluentCMD v0.1.0 *** +*** FluentCMD v0.3.0 *** Reading JSON resume: foo/resume.json Generating HTML resume: out/resume.html Generating TXT resume: out/resume.txt @@ -60,6 +60,17 @@ Generating PDF resume: out/resume.pdf ## Advanced +### Applying a theme + +You can specify a predefined or custom theme via the `-t` parameter. For a predefined theme, include the theme name. For a custom theme, include the path to the custom theme's folder. + +```bash +fluentcmd resume.json -t modern +fluentcmd resume.json -t ~/foo/bar/my-custom-theme/ +``` + +As of v0.3.0, available predefined themes are `modern`, `minimist`, `informatic`, and `hello-world`. + ### Merging resumes You can **merge multiple resumes together** by specifying them in order from most generic to most specific: From b1d987c3b44be5f46e9e5931c9e3813c3f08cea6 Mon Sep 17 00:00:00 2001 From: devlinjd Date: Sat, 10 Oct 2015 20:09:09 -0400 Subject: [PATCH 4/7] Bump version. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dcc9fe2..658dcdb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fluentcmd", - "version": "0.2.0", + "version": "0.3.0", "description": "Generate beautiful, targeted resumes from your command line or shell.", "repository": { "type": "git", From d4a3a08aff484219dfeb9b983bef71b2f25727d0 Mon Sep 17 00:00:00 2001 From: devlinjd Date: Sat, 10 Oct 2015 20:11:26 -0400 Subject: [PATCH 5/7] Add JSON format support. --- src/fluentcmd.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fluentcmd.js b/src/fluentcmd.js index dd4f0ac..91d32e2 100644 --- a/src/fluentcmd.js +++ b/src/fluentcmd.js @@ -93,7 +93,8 @@ module.exports = function () { { name: 'txt', ext: 'txt', gen: new FLUENT.TextGenerator() }, { name: 'doc', ext: 'doc', fmt: 'xml', gen: new FLUENT.WordGenerator() }, { name: 'pdf', ext: 'pdf', fmt: 'html', is: false, gen: new FLUENT.HtmlPdfGenerator() }, - { name: 'markdown', ext: 'md', fmt: 'txt', gen: new FLUENT.MarkdownGenerator() } + { name: 'markdown', ext: 'md', fmt: 'txt', gen: new FLUENT.MarkdownGenerator() }, + { name: 'json', ext: 'json', gen: new FLUENT.JsonGenerator() } ]; /** From cf15738f588c2b0e8be9eafe04825f20a0c4926d Mon Sep 17 00:00:00 2001 From: devlinjd Date: Sat, 10 Oct 2015 21:38:06 -0400 Subject: [PATCH 6/7] Fix explicit output file bug. Fixes a bug that occurs when an explicit output file with an extension other than .all is specified on the command line. --- src/fluentcmd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fluentcmd.js b/src/fluentcmd.js index 91d32e2..c677d89 100644 --- a/src/fluentcmd.js +++ b/src/fluentcmd.js @@ -50,7 +50,7 @@ module.exports = function () { var to = path.resolve(t), pa = path.parse(to), fmat = pa.ext || '.all'; targets.push.apply(targets, fmat === '.all' ? _fmts.map(function(z){ return { file: to.replace(/all$/g,z.ext), fmt: z } }) - : [{ file: to, fmt: z }]); + : [{ file: to, fmt: _.findWhere( _fmts, { ext: fmat.substring(1) }) }]); }); // Run the transformation! From 2e5a68d94258c7c931d5af96be730b3398021f02 Mon Sep 17 00:00:00 2001 From: devlinjd Date: Sat, 10 Oct 2015 21:39:32 -0400 Subject: [PATCH 7/7] Support explicit -o output parameter. Allow output files to be explicitly specified via -o, for ex: fluentcmd resume.json -o out/resume.html -o out/resume.pdf --- src/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index f8d97d4..fd588e8 100644 --- a/src/index.js +++ b/src/index.js @@ -13,8 +13,9 @@ try { console.log( '*** FluentCMD v' + PKG.version + ' ***' ); if( process.argv.length <= 2 ) { throw { fluenterror: 3 }; } var args = ARGS( process.argv.slice(2) ); - var src = args._.filter( function( a ) { return a.match(/\.json$/); }); - var dst = args._.filter( function( a ) { return !a.match(/\.json$/); }); + var src = args._ || []; + var dst = (args.o && ((typeof args.o === 'string' && [ args.o ]) || args.o)) || []; + dst = (dst === true) ? [] : dst; // handle -o with missing output file FCMD.generate( src, dst, args.t || 'modern' ); process.platform !== 'win32' && console.log('\n'); } @@ -22,7 +23,7 @@ catch( ex ) { var msg = ''; if( ex.fluenterror ){ - switch( ex.fluenterror ) { + 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 JSON resume file."; break;