diff --git a/bin/carto b/bin/carto index 78392f7..157655c 100755 --- a/bin/carto +++ b/bin/carto @@ -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 "); 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) { @@ -87,14 +70,14 @@ fs.readFile(input, 'utf-8', function (e, data) { } else { throw err; } - + process.exit(1); } else { if (!options.benchmark) { sys.puts(output); } else { var duration = (+new Date) - start; - console.log('Benchmark: ' + (duration) + 'ms'); + console.log('TOTAL: ' + (duration) + 'ms'); } } }); diff --git a/lib/carto/index.js b/lib/carto/index.js index b2e991b..93c7021 100644 --- a/lib/carto/index.js +++ b/lib/carto/index.js @@ -5,7 +5,7 @@ var path = require('path'), require.paths.unshift(path.join(__dirname, '..')); var carto = { - version: [1, 0, 40], + version: [0, 1, 0], Parser: require('carto/parser').Parser, Renderer: require('carto/renderer').Renderer, External: require('carto/external'), diff --git a/lib/carto/renderer.js b/lib/carto/renderer.js index c08c6a8..313ee92 100644 --- a/lib/carto/renderer.js +++ b/lib/carto/renderer.js @@ -13,7 +13,6 @@ require.paths.unshift(path.join(__dirname, '..', 'lib')); // This is node-only for the time being. carto.Renderer = function Renderer(env) { env = _.extend({}, env); - if (!env.debug) env.debug = false; if (!env.data_dir) env.data_dir = '/tmp/'; if (!env.local_data_dir) env.local_data_dir = ''; if (!env.validation_data) env.validation_data = false; @@ -201,9 +200,9 @@ carto.Renderer = function Renderer(env) { ), { filename: result[0] }); new carto.Parser(parse_env).parse(result[1], function(err, tree) { - if (env.debug) console.warn('Parsing time: ' + if (env.benchmark) console.warn('Parsing time: ' + ((new Date - parsingTime)) - + 'ms (' + result[0] + ')'); + + 'ms'); try { next(err, [ result[0], @@ -299,7 +298,7 @@ carto.Renderer = function Renderer(env) { } } - if (env.debug) console.warn('Inheritance time: ' + ((new Date - inheritTime)) + 'ms'); + if (env.benchmark) console.warn('Inheritance time: ' + ((new Date - inheritTime)) + 'ms'); return result; }, @@ -464,12 +463,12 @@ carto.Renderer = function Renderer(env) { this.localizeExternals(m, function(err, res) { that.ensureSRS(res, function(err, res) { that.localizeStyle(res, function(err, res) { - if (env.debug) console.warn('Localizing time: ' + if (env.benchmark) console.warn('Localizing time: ' + ((new Date - localizingTime)) + 'ms'); that.style(res, function(err, m, res) { var compilingTime = +new Date; that.template(err, m, res, function(err, res) { - if (env.debug) console.warn('COMPILING TIME: ' + if (env.benchmark) console.warn('Compiling time: ' + ((new Date - compilingTime)) + 'ms'); callback(err, res); });