 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("/")

  for test in tests
    console.log("http://#{host}:#{port}/#{test.replace(/\.js$/, "")}")

commands =

  install: () ->

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

  command = argv._[0]
