2016-09-21 21:52:35 +02:00
|
|
|
/*#
|
2018-11-19 03:47:24 +01:00
|
|
|
MapSCII - Terminal Map Viewer
|
2016-09-21 21:52:35 +02:00
|
|
|
by Michael Strassburger <codepoet@cpan.org>
|
|
|
|
Discover the planet in your console!
|
|
|
|
|
|
|
|
This scripts boots up the application.
|
|
|
|
|
|
|
|
TODO: params parsing and so on
|
|
|
|
#*/
|
2024-11-03 10:42:19 +01:00
|
|
|
import config from './src/config.ts';
|
|
|
|
import Mapscii from './src/Mapscii.ts';
|
2024-11-02 16:01:04 +01:00
|
|
|
import yargs from 'yargs/yargs';
|
|
|
|
import { hideBin } from 'yargs/helpers';
|
|
|
|
|
|
|
|
const argv = yargs(hideBin(process.argv))
|
2020-08-12 01:44:39 +02:00
|
|
|
.option('latitude', {
|
|
|
|
alias: 'lat',
|
|
|
|
description: 'Latitude of initial centre',
|
|
|
|
default: config.initialLat,
|
|
|
|
type: 'number',
|
|
|
|
})
|
|
|
|
.option('longitude', {
|
|
|
|
alias: 'lon',
|
|
|
|
description: 'Longitude of initial centre',
|
|
|
|
default: config.initialLon,
|
|
|
|
type: 'number',
|
|
|
|
})
|
|
|
|
.option('zoom', {
|
|
|
|
alias: 'z',
|
|
|
|
description: 'Initial zoom',
|
|
|
|
default: config.initialZoom,
|
|
|
|
type: 'number',
|
|
|
|
})
|
|
|
|
.option('width', {
|
|
|
|
alias: 'w',
|
2020-08-12 01:58:25 +02:00
|
|
|
description: 'Fixed width of rendering',
|
2020-08-12 01:44:39 +02:00
|
|
|
type: 'number',
|
|
|
|
})
|
|
|
|
.option('height', {
|
|
|
|
alias: 'h',
|
2020-08-12 01:58:25 +02:00
|
|
|
description: 'Fixed height of rendering',
|
2020-08-12 01:44:39 +02:00
|
|
|
type: 'number',
|
|
|
|
})
|
|
|
|
.option('braille', {
|
|
|
|
alias: 'b',
|
|
|
|
description: 'Activate braille rendering',
|
|
|
|
default: config.useBraille,
|
|
|
|
type: 'boolean',
|
|
|
|
})
|
|
|
|
.option('headless', {
|
|
|
|
alias: 'H',
|
|
|
|
description: 'Activate headless mode',
|
|
|
|
default: config.headless,
|
|
|
|
type: 'boolean',
|
|
|
|
})
|
|
|
|
.option('tile_source', {
|
|
|
|
alias: 'tileSource',
|
|
|
|
description: 'URL or path to osm2vectortiles source',
|
|
|
|
default: config.source,
|
|
|
|
type: 'string',
|
|
|
|
})
|
|
|
|
.option('style_file', {
|
|
|
|
alias: 'style',
|
|
|
|
description: 'path to json style file',
|
|
|
|
default: config.styleFile,
|
|
|
|
type: 'string',
|
|
|
|
})
|
|
|
|
.strict()
|
|
|
|
.argv;
|
2016-09-21 21:52:35 +02:00
|
|
|
|
2020-08-12 01:44:39 +02:00
|
|
|
const options = {
|
|
|
|
initialLat: argv.latitude,
|
|
|
|
initialLon: argv.longitude,
|
|
|
|
initialZoom: argv.zoom,
|
|
|
|
size: {
|
|
|
|
width: argv.width,
|
|
|
|
height: argv.height
|
|
|
|
},
|
|
|
|
useBraille: argv.braille,
|
|
|
|
headless: argv.headless,
|
|
|
|
source: argv.tile_source,
|
|
|
|
styleFile: argv.style_file,
|
2020-08-12 01:58:25 +02:00
|
|
|
};
|
2020-08-12 01:44:39 +02:00
|
|
|
|
|
|
|
const mapscii = new Mapscii(options);
|
2018-11-19 09:17:12 +01:00
|
|
|
mapscii.init().catch((err) => {
|
|
|
|
console.error('Failed to start MapSCII.');
|
|
|
|
console.error(err);
|
|
|
|
});
|