"use strict";
var _this = this;
var node = require("../package.json").engines.node;
require("./common/verify-node-version").verifyNodeVersion(node, "NativeScript", "2.2.0");
require("./bootstrap");
var fiber = require("fibers");
var Future = require("fibers/future");
var shelljs = require("shelljs");
shelljs.config.silent = true;
var errors_1 = require("./common/errors");
errors_1.installUncaughtExceptionListener(process.exit);
fiber(function () {
    var config = $injector.resolve("$config");
    var err = $injector.resolve("$errors");
    err.printCallStack = config.DEBUG;
    var commandDispatcher = $injector.resolve("commandDispatcher");
    var messages = $injector.resolve("$messagesService");
    messages.pathsToMessageJsonFiles = [];
    var processService = $injector.resolve("$processService");
    processService.attachToProcessExitSignals(_this, process.exit);
    if (process.argv[2] === "completion") {
        commandDispatcher.completeCommand().wait();
    }
    else {
        commandDispatcher.dispatchCommand().wait();
    }
    $injector.dispose();
    Future.assertNoFutureLeftBehind();
}).run();
