batman.coffeesrc/tools/ | |
|---|---|
`#!/usr/bin/env node
` | |
| batman.coffee batman.js Created by Nick Small Copyright 2011, Shopify | (->
cli = require './cli'
Batman = require '../lib/batman.js'
global.RUNNING_IN_BATMAN = true |
| List of commands for use in the multiple | Commands = ['server', 'generate', 'new'] |
| Yeah, this is happening. Sorry everyone.
cli needs to be headlocked into not fatal erroring if no command is given when
help is disabled. We need to disable help so the second parse (the one
in the command file) can spit out its own command specific usage stuff if the
help flag is given with a command. So, we disable the help module here, and
catch the | |
| Disable the help and grab a pointer to the old | cli.disable 'help'
oldFatal = cli.fatal
noCommandGiven = false |
| Provide a | cli.fatal = (str) ->
if str.match 'command is required'
noCommandGiven = true
cli.enable('help').parse(null, Commands)
process.exit()
else
oldFatal(str) |
| Run the parse and then revert this dirty, dirty hack. | cli.parse null, Commands
cli.fatal = oldFatal
cli.enable 'help' |
File Breakout | |
| Effectively reset cli's parsing. | cli.setArgv(process.argv) |
| Finally, we can actually start doing some work. | switch cli.command
when 'serve', 'server'
require('./server')
when 'generate', 'new'
require('./generator')
)()
|