 color = (require "ansi-color").set
 
 options = (require 'optimist')
-    .usage("Watches for changes on provided directory and uploads to simulate\n Usage:$0")
+    .usage("Watches for changes on provided directory and uploads to simulate")
     .options("c", {
         alias: "config_file"
         describe: "Path to config file"

    })
    .options("w", {
        alias: "watch_dir"
        describe: "Directory to watch"
        default: __dirname
    })
    .options("s", {
        alias: "sim_path"
        describe: "Path to simulation in author/sim_path format."
        demand: true
    })
    .options("i", {
        alias: "ignore"
        describe: "Regex with pattern of files to ignore of simulation"
    })
    .argv


upload = (path_to_file, stats) ->
    list = path_to_file.split('/')
    folder = if list.length > 1 then list[0..(list.length - 2)].join('/') else ''

    serverPath = path_to_file.replace(options.watch_dir, '')
    simPath = "#{options.sim_path}/#{serverPath}"

    exec "#{__dirname}/upload.sh #{path_to_file} #{simPath} #{dataObj.user_name} #{dataObj.password}", (err, stdout, stderr) ->
        if err or stderr
            console.error color(err, "red"), stderr, stdout
        else
            console.log serverPath, color("\u2192", "cyan"), "#{simPath}"

watcher.on "change", upload
watcher.on "add", upload
