diff --git a/README.md b/README.md index bc80bac..ada6120 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ fluentcmd in1.json in2.json -o out.html -o out.doc -o out.pdf You should see something to the effect of: ``` -*** FluentCMD v0.3.1 *** +*** FluentCMD v0.4.0 *** Reading JSON resume: foo/resume.json Generating HTML resume: out/resume.html Generating TXT resume: out/resume.txt @@ -78,7 +78,7 @@ fluentcmd resume.json -t modern fluentcmd resume.json -t ~/foo/bar/my-custom-theme/ ``` -As of v0.3.1, available predefined themes are `modern`, `minimist`, `informatic`, and `hello-world`. +As of v0.4.0, available predefined themes are `modern`, `minimist`, and `hello-world`. ### Merging resumes @@ -129,6 +129,14 @@ fluentcmd me.json -o out/resume.all ..tells FluentCV to read `me.json` and generate `out/resume.md`, `out/resume.doc`, `out/resume.html`, `out/resume.txt`, `out/resume.pdf`, and `out/resume.json`. +### Prettifying + +FluentCMD applies [js-beautify][10]-style HTML prettification by default to HTML-formatted resumes. To disable prettification, the `--nopretty` or `-n` flag can be used: + +```bash +fluentcmd resume.json out.all --nopretty +``` + ## License MIT. Go crazy. See [LICENSE.md][1] for details. @@ -142,3 +150,4 @@ MIT. Go crazy. See [LICENSE.md][1] for details. [7]: http://fluentcv.com [8]: https://youtu.be/N9wsjroVlu8 [9]: https://api.jquery.com/jquery.extend/ +[10]: https://github.com/beautify-web/js-beautify diff --git a/package.json b/package.json index c441c6e..11570d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fluentcmd", - "version": "0.3.1", + "version": "0.4.0", "description": "Generate beautiful, targeted resumes from your command line or shell.", "repository": { "type": "git", @@ -24,7 +24,7 @@ }, "homepage": "https://github.com/fluentdesk/fluentcmd", "dependencies": { - "fluentlib": "fluentdesk/fluentlib#v0.2.0", + "fluentlib": "fluentdesk/fluentlib#v0.3.0", "minimist": "^1.2.0", "underscore": "^1.8.3" } diff --git a/src/fluentcmd.js b/src/fluentcmd.js index c677d89..9d8eced 100644 --- a/src/fluentcmd.js +++ b/src/fluentcmd.js @@ -22,11 +22,14 @@ module.exports = function () { @param theme Friendly name of the resume theme. Defaults to "modern". @param logger Optional logging override. */ - function gen( src, dst, theme, logger, errHandler ) { + function gen( src, dst, opts, logger, errHandler ) { _log = logger || console.log; _err = errHandler || error; - _opts.theme = (theme && theme.toLowerCase().trim()) || 'modern'; + + //_opts = extend( true, _opts, opts ); + _opts.theme = (opts.theme && opts.theme.toLowerCase().trim()) || 'modern'; + _opts.prettify = opts.prettify === true ? _opts.prettify : false; // Load input resumes... if(!src || !src.length) { throw { fluenterror: 3 }; } @@ -71,7 +74,7 @@ module.exports = function () { var fObj = _fmts.filter( function(_f) { return _f.ext === fType; } )[0]; var fOut = path.join( f.substring( 0, f.lastIndexOf('.') + 1 ) + fObj.ext ); _log( 'Generating ' + fi.fmt.name.toUpperCase() + ' resume: ' + path.relative(process.cwd(), f ) ); - return fObj.gen.generate( rez, fOut, _opts.theme ); + return fObj.gen.generate( rez, fOut, _opts ); } catch( ex ) { _err( ex ); @@ -98,11 +101,17 @@ module.exports = function () { ]; /** - Default options. + Default FluentCMD options. */ var _opts = { theme: 'modern', - } + prettify: { // ← See https://github.com/beautify-web/js-beautify#options + indent_size: 2, + unformatted: ['em','strong'], + max_char: 80, // ← See lib/html.js in above-linked repo + //wrap_line_length: 120, ← Don't use this + } + }; /** Internal module interface. Used by FCV Desktop and HMR. diff --git a/src/index.js b/src/index.js index fd588e8..5ef1637 100644 --- a/src/index.js +++ b/src/index.js @@ -10,17 +10,38 @@ var ARGS = require( 'minimist' ) , PKG = require('../package.json'); try { + main(); +} +catch( ex ) { + handleError( ex ); +} + +function main() { + // Setup. console.log( '*** FluentCMD v' + PKG.version + ' ***' ); if( process.argv.length <= 2 ) { throw { fluenterror: 3 }; } + + // Convert arguments to source files, target files, options var args = ARGS( process.argv.slice(2) ); 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' ); + dst = (dst === true) ? [] : dst; // Handle -o with missing output file + + // Generate! + FCMD.generate( src, dst, getOpts( args ) ); process.platform !== 'win32' && console.log('\n'); } -catch( ex ) { +function getOpts( args ) { + var noPretty = args['nopretty'] || args.n; + noPretty = noPretty && (noPretty === true || noPretty === 'true'); + return { + theme: args.t || 'modern', + prettify: !noPretty + }; +} + +function handleError( ex ) { var msg = ''; if( ex.fluenterror ){ switch( ex.fluenterror ) { // TODO: Remove magic numbers