1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2025-07-09 11:41:07 +01:00

Add baseline support for -d or --debug flag.

For now, -d just force-emits the stack when there is one. In the future,
it can trigger more detailed logging info.
This commit is contained in:
hacksalot
2016-01-08 16:08:33 -05:00
parent f4e763bd9c
commit 9fdfd1b5a6
4 changed files with 23 additions and 16 deletions

View File

@ -49,7 +49,8 @@ function main() {
.option('-o --opts <optionsFile>', 'Path to a .hackmyrc options file')
.option('-s --silent', 'Run in silent mode')
.option('--no-color', 'Disable colors')
.option('--color', 'Enable colors');
.option('--color', 'Enable colors')
.option('-d --debug', 'Enable diagnostics', false);
//.usage('COMMAND <sources> [TO <targets>]');
// Create the NEW command
@ -172,6 +173,7 @@ Invoke a HackMyResume verb.
*/
function execVerb( src, dst, opts, log ) {
loadOptions.call( this, opts );
require('./core/error-handler').init( _opts.debug );
HMR.verbs[ this.name() ].call( null, src, dst, _opts, log );
}
@ -180,23 +182,24 @@ function execVerb( src, dst, opts, log ) {
/**
Initialize HackMyResume options.
*/
function loadOptions( opts ) {
function loadOptions( o ) {
opts.opts = this.parent.opts;
o.opts = this.parent.opts;
// Load the specified options file (if any) and apply options
if( opts.opts && String.is( opts.opts )) {
var json = safeLoadJSON( PATH.relative( process.cwd(), opts.opts ) );
json && ( opts = EXTEND( true, opts, json ) );
if( o.opts && String.is( o.opts )) {
var json = safeLoadJSON( PATH.relative( process.cwd(), o.opts ) );
json && ( o = EXTEND( true, o, json ) );
if( !json ) {
throw safeLoadJSON.error;
}
}
// Merge in command-line options
opts = EXTEND( true, opts, this.opts() );
opts.silent = this.parent.silent;
_opts = opts;
o = EXTEND( true, o, this.opts() );
o.silent = this.parent.silent;
o.debug = this.parent.debug;
_opts = o;
}