/** Definition of the `main` function. @module cli/main @license MIT. See LICENSE.md for details. */ (function() { var Command, EXTEND, FS, HME, HMR, HMSTATUS, M2C, OUTPUT, PAD, PATH, PKG, StringUtils, _, _err, _exitCallback, _opts, _out, _title, chalk, execute, executeFail, executeSuccess, initOptions, initialize, loadOptions, logMsg, main, 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'); HME = require('../core/event-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). */ main = module.exports = function(rawArgs, exitCallback) { var args, initInfo, program; initInfo = initialize(rawArgs, exitCallback); args = initInfo.args; 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; 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); })); program.command('validate')["arguments"]('').description('Validate a resume in FRESH or JSON RESUME format.').action(function(sources) { execute.call(this, sources, [], this.opts(), logMsg); }); program.command('convert').description('Convert a resume to/from FRESH or JSON RESUME format.').action(function() { var x; x = splitSrcDest.call(this); execute.call(this, x.src, x.dst, this.opts(), logMsg); }); program.command('analyze')["arguments"]('').description('Analyze one or more resumes.').action(function(sources) { execute.call(this, sources, [], this.opts(), logMsg); }); program.command('peek')["arguments"]('').description('Peek at a resume field or section').action(function(sources, sectionOrField) { var dst; dst = sources && sources.length > 1 ? [sources.pop()] : []; execute.call(this, sources, dst, this.opts(), logMsg); }); program.command('build').alias('generate').option('-t --theme ', 'Theme name or path').option('-n --no-prettify', 'Disable HTML prettification', true).option('-c --css