     require("optimist").showHelp()
     process.exit 1
 
-  commands[command](argv._[1..]...)
-
+  commands[command].action(argv._[1..]...)
+

  config: (config) ->
    JSON.stringify config, null, "    "

commands =

  install: () ->
    components = allComponents()
    componentsDirName = join testDirectory(), "static/components"
    provide componentsDirName
    for component in components
      src = join(component.path, sourceDirectory(component.path))
      name = componentName(null, component.json)
      installTo componentsDirName, argv.link, src, name
    if isComponent()
      installTo componentsDirName, argv.link, 'src', componentName()

  test: () ->
    port = process.env.PORT || 1335
    host = process.env.HOST || "localhost"
    components = allComponents()
    staticDirName = join testDirectory(), "static"
    return listTests(discoverTests(staticDirName), host, port) if argv.listtests
    commands.install()
    tests = discoverTests staticDirName
    extraHtml = getTestTemplate() + "\n" + stringBundlesAsRequirejsModule()
    testServer
      .createServer(staticDirName, getConfig(), extraHtml, getTestMiddleware())
      .listen(port, host)
    console.log "serving at http://#{host}:#{port}"
    console.log "available tests:"
    listTests tests, host, port

  template: (cmd, args...) ->
    templateCommands[cmd] getConfig()

  build: () ->
    commands.install()

    staticDirName = join testDirectory(), "static"
    provide argv.staticpath
    wrench.copyDirSyncRecursive staticDirName, argv.staticpath

    config = getConfig()
    templateObj = _.reduce(templateCommands, ((templateObj, cmd, name) ->
      templateObj[name] = templateCommands[name](config)
      return templateObj
    ), {})
    provide argv.templatepath
    contextjsonname = join(argv.templatepath, argv.contextjsonname)
    write contextjsonname, JSON.stringify(templateObj)


commandNames = _.reduce(commands, ((memo, v, k) ->

yaml = require "js-yaml"
testServer = require "./server"

read = (fname, encoding="utf8") ->
  fs.readFileSync(fname, encoding)
write = (fname, content, encoding="utf8") ->
  fs.writeFileSync(fname, content, encoding)
exists = path.existsSync
join = path.join
pathSep = path.normalize("/")
argv = null
usage = null

pkgJson = (dir = ".") ->
  JSON.parse read(join(dir, "package.json"))
