(function() { /** Definition of the `main` function. @module cli/main @license MIT. See LICENSE.md for details. */ /* Invoke a HackMyResume verb. */ /* Success handler for verb invocations. Calls process.exit by default */ /* Init options prior to setting up command infrastructure. */ /* Massage command-line args and setup Commander.js. */ /* Initialize HackMyResume options. TODO: Options loading is a little hacky, for two reasons: - Commander.js idiosyncracies - Need to accept JSON inputs from the command line. */ /* Simple logging placeholder. */ /* Split multiple command-line filenames by the 'TO' keyword */ var Command, EXTEND, FS, HMR, HMSTATUS, M2C, OUTPUT, PAD, PATH, PKG, _, _err, _exitCallback, _opts, _out, _title, chalk, execute, executeFail, executeSuccess, initOptions, initialize, loadOptions, logMsg, printf, safeLoadJSON, splitSrcDest; HMR = require('../index'); PKG = require('../../package.json'); FS = require('fs'); EXTEND = require('extend'); chalk = require('chalk'); PATH = require('path'); HMSTATUS = require('../core/status-codes'); safeLoadJSON = require('../utils/safe-json-loader'); //StringUtils = require '../utils/string.js' _ = require('underscore'); OUTPUT = require('./out'); PAD = require('string-padding'); Command = require('commander').Command; M2C = require('../utils/md2chalk'); printf = require('printf'); _opts = {}; _title = chalk.white.bold('\n*** HackMyResume v' + PKG.version + ' ***'); _out = new OUTPUT(_opts); _err = require('./error'); _exitCallback = null; /* 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). */ module.exports = function(rawArgs, exitCallback) { var args, initInfo, program; initInfo = initialize(rawArgs, exitCallback); if (initInfo === null) { return; } args = initInfo.args; // Create the top-level (application) command... program = new Command('hackmyresume').version(PKG.version).description(chalk.yellow.bold('*** HackMyResume ***')).option('-s --silent', 'Run in silent mode').option('--no-color', 'Disable colors').option('--color', 'Enable colors').option('-d --debug', 'Enable diagnostics', false).option('-a --assert', 'Treat warnings as errors', false).option('-v --version', 'Show the version').allowUnknownOption(); program.jsonArgs = initInfo.options; // Create the NEW command program.command('new').arguments('').option('-f --format ', 'FRESH or JRS format', 'FRESH').alias('create').description('Create resume(s) in FRESH or JSON RESUME format.').action((function(sources) { execute.call(this, sources, [], this.opts(), logMsg); })); // Create the VALIDATE command program.command('validate').arguments('').description('Validate a resume in FRESH or JSON RESUME format.').action(function(sources) { execute.call(this, sources, [], this.opts(), logMsg); }); // Create the CONVERT command program.command('convert').description('Convert a resume to/from FRESH or JSON RESUME format.').option('-f --format ', 'FRESH or JRS format and optional version', void 0).action(function() { var x; x = splitSrcDest.call(this); execute.call(this, x.src, x.dst, this.opts(), logMsg); }); // Create the ANALYZE command program.command('analyze').arguments('').option('--private', 'Include resume fields marked as private', false).description('Analyze one or more resumes.').action(function(sources) { execute.call(this, sources, [], this.opts(), logMsg); }); // Create the PEEK command //.action(( sources, sectionOrField ) -> program.command('peek').arguments('').description('Peek at a resume field or section').action(function(sources) { var dst; dst = (sources && sources.length > 1) ? [sources.pop()] : []; execute.call(this, sources, dst, this.opts(), logMsg); }); // Create the BUILD command //.action(( sources, targets, options ) -> program.command('build').alias('generate').option('-t --theme ', 'Theme name or path').option('-n --no-prettify', 'Disable HTML prettification', true).option('-c --css