Commit a4ab5fec authored by Leo Iannacone's avatar Leo Iannacone

better parser code

parent 499acae4
path = require('path') path = require('path')
Parser = -> class Parser
args = process.argv[2..] constructor: ->
@args = process.argv[2..]
@name = process.argv[1].split("/").pop()
if '-h' in @args
@help()
help = -> help: ->
console.log """ console.log """
Usage: %s [-c config] Usage: %s [-c config]
-h print this help -h print this help
-c set user configuration file -c set user configuration file
""", process.argv[1].split("/").pop() """, @name
process.exit 1 process.exit 1
return return
@getUserConfig = -> getUserConfig: ->
if '-c' in args if '-c' in @args
if args.length < 2 if @args.length < 2
help() @help()
user_config = args[args.indexOf('-c') + 1] user_config = @args[@args.indexOf('-c') + 1]
if user_config[0] isnt '/' if user_config[0] isnt '/'
user_config = process.cwd() + "/" + user_config user_config = process.cwd() + "/" + user_config
return path.normalize(user_config) return path.normalize(user_config)
return null return null
if '-h' in args
help()
module.exports = Parser module.exports = Parser
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment