-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharguments.js
88 lines (85 loc) · 2.13 KB
/
arguments.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import parser from 'yargs/yargs.js';
export function getParser(processArgs) {
return parser(processArgs)
.usage('Usage: $0 [options]')
.example(
'node $0 -i "input1.gpx" "input2.kml" -s OpenStreetMap',
'Download tiles 10-15 along the coordinates from both input files, from OpenStreetMap default tile server',
)
.options({
inputFiles: {
alias: 'i',
conflicts: 'r',
// demandOption: true,
describe: 'An array of input gpx/kml files',
normalize: true,
type: 'array',
},
routeAttribution: {
alias: 'ra',
describe: 'The source of the input files',
type: 'string',
},
relationId: {
alias: 'r',
conflicts: 'i',
// demandOption: true,
describe: 'An OSM relation Id',
type: 'number',
},
sourceType: {
alias: 'st',
choices: ['Maperitive', 'MB', 'FS', 'WMTS'],
describe: 'Source type',
default: 'WMTS',
},
sourceFile: {
alias: 'sf',
describe: 'Source file',
type: 'string',
},
sourceName: {
alias: 'sn',
describe: 'Source tile server name',
type: 'string',
},
minZoom: {
alias: 'min',
default: 10,
describe: 'Minimum required zoom',
type: 'number',
},
maxZoom: {
alias: 'max',
default: 15,
describe: 'Maximum required zoom',
type: 'number',
},
outputFile: {
alias: 'of',
describe: 'Output file name',
normalize: true,
type: 'string',
},
outputType: {
alias: 'ot',
choices: ['MBTiles', 'BCNav', 'Both'],
default: 'Both',
},
})
.help('h')
.alias('h', 'help')
.check(({minZoom, maxZoom}) => {
if (minZoom < 0) {
throw new Error('minZoom must be >= 0');
}
if (minZoom > maxZoom) {
throw new Error('minZoom must be <= maxZoom');
}
if (maxZoom > 20) {
throw new Error('maxZoom must be <= 20');
}
return true;
})
.epilog('copyright 2017');
}