1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-07-08 10:40:04 +01:00
HackMyResume/src/index.js

39 lines
1.2 KiB
JavaScript
Raw Normal View History

#! /usr/bin/env node
/**
2015-10-06 17:21:22 +01:00
Command-line interface (CLI) for FluentCMD via Node.js.
@license Copyright (c) 2015 | James M. Devlin
*/
var ARGS = require( 'minimist' )
2015-10-07 14:29:41 +01:00
, FCMD = require( './fluentcmd')
, PKG = require('../package.json');
try {
2015-10-07 14:29:41 +01:00
console.log( '*** FluentCMD v' + PKG.version + ' ***' );
if( process.argv.length <= 2 ) { throw { fluenterror: 3 }; }
var args = ARGS( process.argv.slice(2) );
2015-10-07 14:29:41 +01:00
var src = args._.filter( function( a ) { return a.match(/\.json$/); });
var dst = args._.filter( function( a ) { return !a.match(/\.json$/); });
2015-10-06 17:21:22 +01:00
FCMD.generate( src, dst, args.t || 'informatic' );
process.platform !== 'win32' && console.log('\n');
}
catch( ex ) {
2015-10-07 14:29:41 +01:00
var msg = '';
if( ex.fluenterror ){
switch( ex.fluenterror ) {
case 1: msg = "The specified theme couldn't be found: " + ex.data; break;
case 2: msg = "Couldn't copy CSS file to destination folder"; break;
case 3: msg = "Please specify a valid JSON resume file."; break;
};
}
else {
msg = ex.toString();
}
var idx = msg.indexOf('Error: ');
var trimmed = idx === -1 ? msg : msg.substring( idx + 7 );
console.log( 'ERROR: ' + trimmed.toString() );
}