-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.js
36 lines (32 loc) · 1011 Bytes
/
main.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
#!/usr/bin/env node
require('source-map-support').install();
const program = require('commander');
const run = require('./lib/run').run;
const version = require('./package.json').version;
program
.version(version)
// TODO: Add valid parser names automatically:
.option(
'-p, --parser [parser]',
'The name of the parser to use, either "json" or "python".'
)
.option('-o, --outputdir [outputdir]', 'The output directory.')
.option('-t, --template [template]', 'a template file to use.')
.option(
'-e, --extension [extension]',
'The file extension to use for the output.'
)
.arguments('<file> [languages...]')
.action(function (file, languages, cmd) {
try {
run(file, languages && languages.length > 0 ? languages : ['python'], {
output: cmd.outputdir,
parserName: cmd.parser,
templateFile: cmd.template,
fileExt: cmd.extension,
});
} catch (error) {
console.error(error.message);
}
})
.parse(process.argv);