|
|
|
@ -8,10 +8,7 @@ require.paths.unshift(path.join(__dirname, '../lib'), path.join(__dirname, '../l
|
|
|
|
|
|
|
|
|
|
var carto = require('carto');
|
|
|
|
|
var args = process.argv.slice(1);
|
|
|
|
|
var options = {
|
|
|
|
|
silent: false,
|
|
|
|
|
json: false
|
|
|
|
|
};
|
|
|
|
|
var options = {};
|
|
|
|
|
|
|
|
|
|
args = args.filter(function (arg) {
|
|
|
|
|
var match;
|
|
|
|
@ -22,29 +19,19 @@ args = args.filter(function (arg) {
|
|
|
|
|
switch (arg) {
|
|
|
|
|
case 'v':
|
|
|
|
|
case 'version':
|
|
|
|
|
sys.puts("cartoc " + carto.version.join('.') + " (MESS Compiler) [JavaScript]");
|
|
|
|
|
sys.puts("carto " + carto.version.join('.') + " (Carto map stylesheet compiler)");
|
|
|
|
|
process.exit(0);
|
|
|
|
|
break;
|
|
|
|
|
case 'verbose':
|
|
|
|
|
options.verbose = true;
|
|
|
|
|
break;
|
|
|
|
|
case 'd':
|
|
|
|
|
case 'debug':
|
|
|
|
|
options.debug = true;
|
|
|
|
|
break;
|
|
|
|
|
case 's':
|
|
|
|
|
case 'silent':
|
|
|
|
|
options.silent = true;
|
|
|
|
|
break;
|
|
|
|
|
case 'b':
|
|
|
|
|
case 'benchmark':
|
|
|
|
|
options.benchmark = true;
|
|
|
|
|
break;
|
|
|
|
|
case 'h':
|
|
|
|
|
case 'help':
|
|
|
|
|
sys.puts("Usage: carto source");
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
sys.puts("Usage: carto <source MML file>");
|
|
|
|
|
sys.puts("Options:");
|
|
|
|
|
sys.puts(" -j\tParse JSON map manifest");
|
|
|
|
|
sys.puts(" -v --version Parse JSON map manifest");
|
|
|
|
|
sys.puts(" -b --benchmark Outputs total compile time");
|
|
|
|
|
process.exit(0);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
@ -54,10 +41,6 @@ var input = args[1];
|
|
|
|
|
if (input && input[0] != '/') {
|
|
|
|
|
input = path.join(process.cwd(), input);
|
|
|
|
|
}
|
|
|
|
|
var output = args[2];
|
|
|
|
|
if (output && output[0] != '/') {
|
|
|
|
|
output = path.join(process.cwd(), output);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!input) {
|
|
|
|
|
sys.puts("carto: no input files");
|
|
|
|
@ -68,15 +51,15 @@ if (options.benchmark) {
|
|
|
|
|
var start = +new Date;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fs.readFile(input, 'utf-8', function (e, data) {
|
|
|
|
|
if (e) {
|
|
|
|
|
sys.puts("carto: " + e.cartoage);
|
|
|
|
|
fs.readFile(input, 'utf-8', function (err, data) {
|
|
|
|
|
if (err) {
|
|
|
|
|
sys.puts("carto: " + err.message.replace(/^[A-Z]+, /, ''));
|
|
|
|
|
process.exit(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
new carto.Renderer({
|
|
|
|
|
filename: input,
|
|
|
|
|
debug: options.debug,
|
|
|
|
|
benchmark: options.benchmark,
|
|
|
|
|
local_data_dir: path.dirname(input),
|
|
|
|
|
}).render(data, function(err, output) {
|
|
|
|
|
if (err) {
|
|
|
|
@ -94,7 +77,7 @@ fs.readFile(input, 'utf-8', function (e, data) {
|
|
|
|
|
sys.puts(output);
|
|
|
|
|
} else {
|
|
|
|
|
var duration = (+new Date) - start;
|
|
|
|
|
console.log('Benchmark: ' + (duration) + 'ms');
|
|
|
|
|
console.log('TOTAL: ' + (duration) + 'ms');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|