UNPKG

998 BPlain TextView Raw
1#!/usr/bin/env node
2// Generated by CoffeeScript 2.3.0
3(function() {
4 //!/usr/bin/env coffee
5 var argv, compiler, input_file, input_text;
6
7 module.paths.unshift(`${require('path').dirname(__dirname)}/lib`);
8
9 require('testml-compiler/prelude');
10
11 require('testml-compiler/compiler');
12
13 argv = process.argv.slice(2);
14
15 if (argv.length !== 1) {
16 die("testml-compiler <testml-file-name> | - | --version");
17 }
18
19 if (argv[0] === '--version') {
20 say(`TestML version '${TestMLCompiler.VERSION}'`);
21 exit(0);
22 } else if (argv[0].match(/^-./)) {
23 die(`Unknown argument '${argv[0]}'`);
24 }
25
26 input_file = argv[0];
27
28 if (input_file == null) {
29 throw "usage: testml-compiler <input-file>";
30 }
31
32 if (!(input_file === '-' || file_exists(input_file))) {
33 throw `Input file does not exist: '${input_file}'`;
34 }
35
36 input_text = read_file(input_file);
37
38 compiler = new TestMLCompiler.Compiler;
39
40 out(compiler.compile(input_text, input_file));
41
42 // vim: sw=2 lisp:
43
44}).call(this);