mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-05 09:56:22 +00:00
Handle global options.
Fix broken --silent flag and set up -o/-opts.
This commit is contained in:
parent
d5e2a45034
commit
c8d4a3deb3
26
src/index.js
26
src/index.js
@ -17,7 +17,7 @@ var SPAWNW = require('./core/spawn-watch')
|
|||||||
, chalk = require('chalk')
|
, chalk = require('chalk')
|
||||||
, PATH = require('path')
|
, PATH = require('path')
|
||||||
, HACKMYSTATUS = require('./core/status-codes')
|
, HACKMYSTATUS = require('./core/status-codes')
|
||||||
, opts = { }
|
, _opts = { }
|
||||||
, title = chalk.white.bold('\n*** HackMyResume v' + PKG.version + ' ***')
|
, title = chalk.white.bold('\n*** HackMyResume v' + PKG.version + ' ***')
|
||||||
, StringUtils = require('./utils/string.js')
|
, StringUtils = require('./utils/string.js')
|
||||||
, _ = require('underscore')
|
, _ = require('underscore')
|
||||||
@ -40,12 +40,20 @@ function main() {
|
|||||||
|
|
||||||
var args = initialize();
|
var args = initialize();
|
||||||
|
|
||||||
|
function execVerb( src, dst, opts, log ) {
|
||||||
|
_opts = opts;
|
||||||
|
_opts.silent = this.parent.silent;
|
||||||
|
_opts.opts = this.parent.opts;
|
||||||
|
FCMD.verbs[ this.name() ].call( null, src, dst, opts, log );
|
||||||
|
}
|
||||||
|
|
||||||
// Create the top-level (application) command...
|
// Create the top-level (application) command...
|
||||||
var program = new Command('hackmyresume')
|
var program = new Command('hackmyresume')
|
||||||
.version(PKG.version)
|
.version(PKG.version)
|
||||||
.description(chalk.yellow.bold('*** HackMyResume ***'))
|
.description(chalk.yellow.bold('*** HackMyResume ***'))
|
||||||
.option('-s, --silent', 'Run in silent mode.')
|
.option('-o --opts <optionsFile>', 'Path to a .hackmyrc options file')
|
||||||
.usage('COMMAND <sources> [TO <targets>]');
|
.option('-s --silent', 'Run in silent mode');
|
||||||
|
//.usage('COMMAND <sources> [TO <targets>]');
|
||||||
|
|
||||||
// Create the NEW command
|
// Create the NEW command
|
||||||
program
|
program
|
||||||
@ -55,7 +63,7 @@ function main() {
|
|||||||
.alias('create')
|
.alias('create')
|
||||||
.description('Create resume(s) in FRESH or JSON RESUME format.')
|
.description('Create resume(s) in FRESH or JSON RESUME format.')
|
||||||
.action(function( sources ) {
|
.action(function( sources ) {
|
||||||
FCMD.verbs[ this.name() ].call( null, sources, [], this.opts(), logMsg);
|
execVerb.call( this, sources, [], this.opts(), logMsg);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create the VALIDATE command
|
// Create the VALIDATE command
|
||||||
@ -64,7 +72,7 @@ function main() {
|
|||||||
.arguments('<sources...>')
|
.arguments('<sources...>')
|
||||||
.description('Validate a resume in FRESH or JSON RESUME format.')
|
.description('Validate a resume in FRESH or JSON RESUME format.')
|
||||||
.action(function(sources) {
|
.action(function(sources) {
|
||||||
FCMD.verbs[ this.name() ].call( null, sources, [], this.opts(), logMsg);
|
execVerb.call( this, sources, [], this.opts(), logMsg);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create the CONVERT command
|
// Create the CONVERT command
|
||||||
@ -74,7 +82,7 @@ function main() {
|
|||||||
.description('Convert a resume to/from FRESH or JSON RESUME format.')
|
.description('Convert a resume to/from FRESH or JSON RESUME format.')
|
||||||
.action(function() {
|
.action(function() {
|
||||||
var x = splitSrcDest.call( this );
|
var x = splitSrcDest.call( this );
|
||||||
FCMD.verbs[ this.name() ].call( null, x.src, x.dst, this.opts(), logMsg);
|
execVerb.call( this, x.src, x.dst, this.opts(), logMsg);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create the ANALYZE command
|
// Create the ANALYZE command
|
||||||
@ -83,7 +91,7 @@ function main() {
|
|||||||
.arguments('<sources...>')
|
.arguments('<sources...>')
|
||||||
.description('Analyze one or more resumes.')
|
.description('Analyze one or more resumes.')
|
||||||
.action(function( sources ) {
|
.action(function( sources ) {
|
||||||
FCMD.verbs[ this.name() ].call( null, sources, [], this.opts(), logMsg);
|
execVerb.call( this, sources, [], this.opts(), logMsg);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create the BUILD command
|
// Create the BUILD command
|
||||||
@ -99,7 +107,7 @@ function main() {
|
|||||||
.description('Generate resume to multiple formats')
|
.description('Generate resume to multiple formats')
|
||||||
.action(function( sources, targets, options ) {
|
.action(function( sources, targets, options ) {
|
||||||
var x = splitSrcDest.call( this );
|
var x = splitSrcDest.call( this );
|
||||||
FCMD.verbs[ this.name() ].call( null, x.src, x.dst, this.opts(), logMsg );
|
execVerb.call( this, x.src, x.dst, this.opts(), logMsg);
|
||||||
});
|
});
|
||||||
|
|
||||||
// program.on('--help', function(){
|
// program.on('--help', function(){
|
||||||
@ -194,5 +202,5 @@ Simple logging placeholder.
|
|||||||
*/
|
*/
|
||||||
function logMsg( msg ) {
|
function logMsg( msg ) {
|
||||||
msg = msg || '';
|
msg = msg || '';
|
||||||
opts.silent || console.log( msg );
|
_opts.silent || console.log( msg );
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,8 @@ Implementation of the 'generate' verb for HackMyResume.
|
|||||||
var numFormats = Object.keys(theme.formats).length;
|
var numFormats = Object.keys(theme.formats).length;
|
||||||
var themeName = theme.name.toUpperCase();
|
var themeName = theme.name.toUpperCase();
|
||||||
_log( chalk.yellow('Applying ') + chalk.yellow.bold(themeName) +
|
_log( chalk.yellow('Applying ') + chalk.yellow.bold(themeName) +
|
||||||
chalk.yellow(' theme (' + numFormats + ' format' + ( numFormats === 1 ? ')' : 's)') ));
|
chalk.yellow(' theme (' + numFormats + ' format' +
|
||||||
|
( numFormats === 1 ? ')' : 's)') ));
|
||||||
|
|
||||||
// Expand output resumes...
|
// Expand output resumes...
|
||||||
var targets = expand( dst, theme );
|
var targets = expand( dst, theme );
|
||||||
@ -135,7 +136,8 @@ Implementation of the 'generate' verb for HackMyResume.
|
|||||||
}
|
}
|
||||||
|
|
||||||
_log( chalk.green('Generating ') +
|
_log( chalk.green('Generating ') +
|
||||||
chalk.green.bold(pad(targInfo.fmt.outFormat.toUpperCase(),4,null,pad.RIGHT)) +
|
chalk.green.bold(
|
||||||
|
pad(targInfo.fmt.outFormat.toUpperCase(),4,null,pad.RIGHT)) +
|
||||||
chalk.green(' resume') + suffix + chalk.green(': ') +
|
chalk.green(' resume') + suffix + chalk.green(': ') +
|
||||||
chalk.green.bold( PATH.relative(process.cwd(), f )) );
|
chalk.green.bold( PATH.relative(process.cwd(), f )) );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user