mirror of
https://github.com/rastapasta/mapscii.git
synced 2024-11-26 01:54:14 +01:00
90 lines
2.0 KiB
TypeScript
90 lines
2.0 KiB
TypeScript
/*#
|
|
MapSCII - Terminal Map Viewer
|
|
by Michael Strassburger <codepoet@cpan.org>
|
|
Discover the planet in your console!
|
|
|
|
This scripts boots up the application.
|
|
|
|
TODO: params parsing and so on
|
|
#*/
|
|
import config from './src/config.ts';
|
|
import Mapscii from './src/Mapscii.ts';
|
|
import yargs from 'yargs/yargs';
|
|
import { hideBin } from 'yargs/helpers';
|
|
|
|
const argv = yargs(hideBin(process.argv))
|
|
.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',
|
|
description: 'Fixed width of rendering',
|
|
type: 'number',
|
|
})
|
|
.option('height', {
|
|
alias: 'h',
|
|
description: 'Fixed height of rendering',
|
|
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;
|
|
|
|
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,
|
|
};
|
|
|
|
const mapscii = new Mapscii(options);
|
|
mapscii.init().catch((err) => {
|
|
console.error('Failed to start MapSCII.');
|
|
console.error(err);
|
|
});
|