#!/usr/bin/env node

var cartero = require( '../' );
var minimist = require( 'minimist' );
var path = require( 'path' );
var fs = require( 'fs' );

/* Note: This is hasn't been tested yet. */

var argv = minimist( process.argv.slice(2),
	{
		alias : {
			keepSeparate : 's',
			maps : 'm',
			watch : 'w',
			transform : 't',
			transformDirs : 'd',
			postProcessor : 'p',
			outputDirUrl : 'u',
			help : 'h'
		},
		boolean : [ 'keepSeparate', 'watch', 'help', 'maps' ]
	}
);

if( argv.help ) {
	return fs.createReadStream( __dirname + '/help.txt' ).pipe( process.stdout ).on( 'close', function() {
		process.exit( 0 );
	} );
}

var viewDirPath = argv._[0];
var outputDirPath = argv._[1];

if( viewDirPath === undefined || outputDirPath === undefined ) {
	console.log( 'Both a viewDir and an outputDir are required' );
	process.exit( 1 );
}

viewDirPath = resolvePath( viewDirPath );
outputDirPath = resolvePath( outputDirPath );

var watch = argv.watch;

var appTransformDirs = argv.transformDirs;
if( typeof appTransformDirs === 'string' ) appTransformDirs = [ appTransformDirs ];

var carteroOptions = {
	keepSeparate : argv.keepSeparate,
	sourceMaps : argv.maps,
	watch : watch,
	appTransforms : argv.transform,
	appTransformDirs : appTransformDirs,
	outputDirUrl : argv.outputDirUrl,
	packageTransform : argv.packageTransform,
	postProcessors : argv.postProcessor
};

var c = cartero( viewDirPath, outputDirPath, carteroOptions );

c.on( 'error', function( err ) {
	console.log( err.stack );
	process.exit( 1 );
} );

c.on( "done", function() {
	if( ! watch )
		process.exit( 0 );
} );

function resolvePath( inputPath ) {
	return inputPath ? path.resolve( inputPath ) : inputPath;
}

@@ -1078,16 +1078,78 @@
 Dirs %5D;%0A
+if( typeof transform === 'string' ) transform = %5B transform %5D;
 %0Avar car

Update cmd.js