Skip to content

Commit

Permalink
Merge pull request #16 from mapbox/positional-mbtiles-param
Browse files Browse the repository at this point in the history
Positional mbtiles param
  • Loading branch information
defvol committed May 7, 2016
2 parents 85da853 + dc42544 commit 2934e7e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,28 @@
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) {
console.log(usage());
process.exit(1);
}

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: 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)');
Expand All @@ -33,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
};

Expand Down

0 comments on commit 2934e7e

Please sign in to comment.