Commit a4ab5fec authored by Leo Iannacone's avatar Leo Iannacone

better parser code

parent 499acae4
path = require('path')
Parser = ->
args = process.argv[2..]
class Parser
constructor: ->
@args = process.argv[2..]
@name = process.argv[1].split("/").pop()
if '-h' in @args
@help()
help = ->
help: ->
console.log """
Usage: %s [-c config]
-h print this help
-c set user configuration file
""", process.argv[1].split("/").pop()
""", @name
process.exit 1
return
@getUserConfig = ->
if '-c' in args
if args.length < 2
help()
user_config = args[args.indexOf('-c') + 1]
getUserConfig: ->
if '-c' in @args
if @args.length < 2
@help()
user_config = @args[@args.indexOf('-c') + 1]
if user_config[0] isnt '/'
user_config = process.cwd() + "/" + user_config
return path.normalize(user_config)
return null
if '-h' in args
help()
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