Add the "verify" script

In addition to the new script, this changes the V2 parser to be able
to continue past the first error found so that as many errors as
possible may be displayed.
This commit is contained in:
Andrew Miner
2015-01-14 15:57:27 -08:00
parent 89a8e2b539
commit 291f94da57
3 changed files with 64 additions and 11 deletions
Executable
+34
View File
@@ -0,0 +1,34 @@
#!/usr/bin/env coffee
global._ = require 'underscore'
global.Backbone = require 'backbone'
fs = require 'fs'
Logger = require '../src/scripts/logger'
ModVersionParser = require '../src/scripts/models/mod_version_parser'
require '../src/scripts/underscore_mixins'
########################################################################################################################
if process.argv.length is 3
sourceFileName = process.argv[2]
else
console.error """
USAGE: verify <source>
Verifies that a recipe book is in the proper format. If there is a problem,
then a message will be displayed. Otherwise, the command has no output.
"""
process.exit -1
global.logger = new Logger level:Logger.WARNING
try
text = fs.readFileSync sourceFileName, 'UTF-8'
parser = new ModVersionParser showAllErrors:true
modVersion = parser.parse text
catch e
console.error e.message