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

  memo
), {})

exports.run = () ->
  argv = require("optimist")
    .usage(usage)

    .boolean(["l", "link"]).alias("l", "link")
    .describe("l", "install components as symlinks (useful for development)")

    .boolean("listtests")
    .describe("listtests", "when running the 'test' command, just list tests")

    .string(["t", "templatepath"]).alias("t", "templatepath")
    .describe("t", "when running 'build', command, specify the templatepath")

    .string(["j", "contextjsonname"]).alias("j", "contextjsonname")
    .default("contextjsonname", "csi-context.json")
    .describe("j", "when running 'build', command, specify the name of the context json")

    .string(["s", "staticpath"]).alias("s", "staticpath")
    .describe("s", "when running 'build', command, specify the staticpath")

    .string(["b", "baseurl"]).alias("b", "baseurl")
    .default("baseurl", "/static")
    .describe("b", "when running 'build', command, specify the baseurl")

    .check((argv) ->
      if argv._[0] is 'build'
        for arg in ['templatepath', 'staticpath']
          if not argv[arg]
            throw Error "'#{arg}' option must be defined for 'build' command"
    )

    .alias("h", "help")

    .argv



provide = (pth) ->
  if not exists pth
    start = if pth[0] is pathSep then pathSep else ""
    _.reduce [start].concat(pth.split(pathSep)), (soFar, dir) ->
      fs.mkdirSync join(soFar, dir) if not exists(join(soFar, dir))
      soFar += (if soFar then pathSep else "") + dir

