diff options
Diffstat (limited to 'rule-compiler/cli.js')
-rw-r--r-- | rule-compiler/cli.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/rule-compiler/cli.js b/rule-compiler/cli.js new file mode 100644 index 00000000..c4a3b291 --- /dev/null +++ b/rule-compiler/cli.js @@ -0,0 +1,29 @@ +'use strict'; + +var fs = require('fs'); + +var RuleCompiler = require('./rule-compiler.js'); + +if (process.argv.length < 3) { + console.log('Usage: node cli.js <rules script>'); + process.exit(1); +} + +var src = fs.readFileSync(process.argv[2]).toString(); + +var rules = []; +var caps = {}; +var tags = {}; +var err = RuleCompiler.compile(src,rules,caps,tags); + +if (err) { + console.log('ERROR parsing '+process.argv[2]+' line '+err[0]+' column '+err[1]+': '+err[2]); + process.exit(1); +} else { + console.log(JSON.stringify({ + rules: rules, + caps: caps, + tags: tags + },null,2)); + process.exit(0); +} |