2015-09-01 06:05:47 +01:00
|
|
|
#! /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
|
2015-09-01 06:05:47 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
var ARGS = require( 'minimist' )
|
2015-10-07 14:29:41 +01:00
|
|
|
, FCMD = require( './fluentcmd')
|
|
|
|
, PKG = require('../package.json');
|
2015-09-01 06:05:47 +01:00
|
|
|
|
|
|
|
try {
|
2015-10-07 14:29:41 +01:00
|
|
|
console.log( '*** FluentCMD v' + PKG.version + ' ***' );
|
|
|
|
if( process.argv.length <= 2 ) { throw { fluenterror: 3 }; }
|
2015-09-01 06:05:47 +01:00
|
|
|
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');
|
2015-09-01 06:05:47 +01:00
|
|
|
}
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2015-09-01 06:05:47 +01:00
|
|
|
var idx = msg.indexOf('Error: ');
|
|
|
|
var trimmed = idx === -1 ? msg : msg.substring( idx + 7 );
|
|
|
|
console.log( 'ERROR: ' + trimmed.toString() );
|
|
|
|
}
|