From 2ca89db53e3aa824075e3346001e1afd04bbaa99 Mon Sep 17 00:00:00 2001 From: Aaron Lidman Date: Fri, 6 May 2016 22:41:03 -0700 Subject: [PATCH 1/3] Make mbtiles parameter positional --- cli.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cli.js b/cli.js index 8a4c3f9..417465a 100644 --- a/cli.js +++ b/cli.js @@ -4,6 +4,7 @@ var argv = require('minimist')(process.argv.slice(2)); var path = require('path'); var open = require('open'); +argv.mbtiles = argv.mbtiles || argv._[0]; if (!argv.mbtiles) { console.log(usage()); process.exit(1); @@ -13,10 +14,10 @@ argv.basemap = argv.basemap || argv.base || argv.map || 'dark'; function usage () { var text = []; - text.push('usage: node cli.js [options]'); + text.push('usage: mbview [file] [options]'); text.push(''); - text.push(' --mbtiles path to mbtiles file'); - text.push(' --port sets port to use'); + text.push(' --mbtiles path to mbtiles file (optional)'); + text.push(' --port sets port to use (default: 3000)'); text.push(' --quiet or -q supress all logging except the address to visit'); text.push(' -n don\'t automatically open the browser on start'); text.push(' --basemap or --base or --map sets the basemap style (default: dark)'); From 931770704aa903c241c1847774175bb31c17f44c Mon Sep 17 00:00:00 2001 From: Aaron Lidman Date: Fri, 6 May 2016 22:42:41 -0700 Subject: [PATCH 2/3] Check that the file exists --- cli.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cli.js b/cli.js index 417465a..a338987 100644 --- a/cli.js +++ b/cli.js @@ -3,6 +3,7 @@ var argv = require('minimist')(process.argv.slice(2)); var path = require('path'); var open = require('open'); +var fs = require('fs'); argv.mbtiles = argv.mbtiles || argv._[0]; if (!argv.mbtiles) { @@ -12,6 +13,12 @@ if (!argv.mbtiles) { argv.basemap = argv.basemap || argv.base || argv.map || 'dark'; +try { + fs.statSync(argv.mbtiles).isFile(); +} catch(e) { + return console.log('*** ' + argv.mbtiles + ' does not exist'); +} + function usage () { var text = []; text.push('usage: mbview [file] [options]'); From dc42544098efa44e97250e7f1b011ff459aeae1b Mon Sep 17 00:00:00 2001 From: Rodolfo Wilhelmy Date: Sat, 7 May 2016 00:30:15 -0700 Subject: [PATCH 3/3] Fix missing comma --- cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli.js b/cli.js index a338987..883c9d6 100644 --- a/cli.js +++ b/cli.js @@ -41,7 +41,7 @@ var params = { sourceLayer: argv.sourceLayer || path.basename(argv.mbtiles, '.mbtiles'), sourceId: 'default', zoom: 12, - quiet: argv.q || argv.quiet + quiet: argv.q || argv.quiet, basemap: argv.basemap };