-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcli.js
More file actions
31 lines (27 loc) · 734 Bytes
/
cli.js
File metadata and controls
31 lines (27 loc) · 734 Bytes
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
#!/usr/bin/node
var log = require('bole')('cli')
var program = require('commander')
var Compiler = require('./index')
var compiler = new Compiler()
var version = require('./package').version
/**
* setup command line parsing
*/
program
.version(version)
.usage('[options]')
.option('-i, --input-file [value]', 'Input file')
.option('-o, --output-file', 'Output file')
.parse(process.argv)
var input = program.args[0] || program.inputFile
var code = compiler.openFile(input)
var output = program.outputFile || program.args[1] || 'out.nes'
try {
var bin = compiler.nesCompiler(code)
compiler.writeFile(output, bin)
} catch (e) {
e.forEach(function (error) {
log.error('Error: ', error)
})
process.exit(1)
}