#!/usr/bin/env coffee
fs = require 'fs'
path = require 'path'
package_json = JSON.parse fs.readFileSync path.join(__dirname, '../package.json')
server = require '../src/server'
doc = """

Usage:
    snakeoil [options] [<directory>] [<port>]

Options:
    --help
    --version

Description:
    #{package_json.description}

Example:
    snakeoil .
    snakeoil . 4567
    snakeoil 
    snakeoil /path/to/my/directory 5000
    snakeoil /path/to/my/file.py

"""
{docopt} = require 'docopt', version: package_json.version
options = docopt doc

# handle arguments
directory = options['<directory>'] || "."
# easier if we use a fully path to the working directory
directory = path.resolve(directory)
port = options['<port>'] || 3000

# start up the server
server directory, port
