/* * decaffeinate suggestions: * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ /** Definition of the `main` function. @module cli/main @license MIT. See LICENSE.md for details. */ const HMR = require('../index'); const PKG = require('../../package.json'); const FS = require('fs'); const EXTEND = require('extend'); const chalk = require('chalk'); const PATH = require('path'); const HMSTATUS = require('../core/status-codes'); const safeLoadJSON = require('../utils/safe-json-loader'); //StringUtils = require '../utils/string.js' const _ = require('underscore'); const OUTPUT = require('./out'); const PAD = require('string-padding'); const { Command } = require('commander'); const M2C = require('../utils/md2chalk'); const printf = require('printf'); const _opts = { }; const _title = chalk.white.bold(`\n*** HackMyResume v${PKG.version} ***`); const _out = new OUTPUT( _opts ); const _err = require('./error'); let _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 ) { const initInfo = initialize( rawArgs, exitCallback ); if (initInfo === null) { return; } const { args } = initInfo; // Create the top-level (application) command... const 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', undefined) .action(function() { const 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 program .command('peek') .arguments('') .description('Peek at a resume field or section') //.action(( sources, sectionOrField ) -> .action(function( sources ) { const dst = (sources && (sources.length > 1)) ? [sources.pop()] : []; execute.call( this, sources, dst, this.opts(), logMsg); }); // Create the BUILD command program .command('build') .alias('generate') .option('-t --theme ', 'Theme name or path') .option('-n --no-prettify', 'Disable HTML prettification', true) .option('-c --css