 uuid    = require('uuid')
 winston = require('winston')
 request = require('request')
-program = require('commander')          # command line arguments -- https://github.com/visionmedia/commander.js/
 
 init_gitconfig = require('./gitconfig').init_gitconfig
 

        # we report and ignore errors
        winston.debug("ERROR set_extra_env -- cannot process '#{process.env.COCALC_EXTRA_ENV}' -- #{err}")

program.usage('[?] [options]')
    .option('--tcp_port <n>', 'TCP server port to listen on (default: 0 = os assigned)', ((n)->parseInt(n)), 0)
    .option('--raw_port <n>', 'RAW server port to listen on (default: 0 = os assigned)', ((n)->parseInt(n)), 0)
    .option('--console_port <n>', 'port to find console server on (optional; uses port file if not given); if this is set we assume some other system is managing the console server and do not try to start it -- just assume it is listening on this port always', ((n)->parseInt(n)), 0)
    .option('--kucalc', "Running in the kucalc environment")
    .option('--test_firewall', 'Abort and exit w/ code 99 if internal GCE information is accessible')
    .option('--test', "Start up everything, then immediately exit.  Used as a test and to ensure coffeescript and typescript is compiled/cache")
    .parse(process.argv)

if program.kucalc
    winston.debug("running in kucalc")

    if err
        process.exit(1)
    if program.test
        winston.debug("Test mode -- waiting 5 seconds")
        setTimeout ->
            winston.debug("Test mode -- now exiting")
            process.exit(0)
        , 5000

