"use strict";
var path = require("path");
var GenerateMessages = (function () {
    function GenerateMessages($fs, $messageContractGenerator, $options) {
        this.$fs = $fs;
        this.$messageContractGenerator = $messageContractGenerator;
        this.$options = $options;
        this.allowedParameters = [];
    }
    GenerateMessages.prototype.execute = function (args) {
        var _this = this;
        return (function () {
            var definitionsPath = "\"" + (_this.$options.default ? "../" : "") + ".d.ts\"", result = _this.$messageContractGenerator.generate(definitionsPath).wait(), innerMessagesDirectory = path.join(__dirname, "../messages"), outerMessagesDirectory = path.join(__dirname, "../.."), interfaceFilePath, implementationFilePath;
            if (_this.$options.default) {
                interfaceFilePath = path.join(innerMessagesDirectory, GenerateMessages.MESSAGES_DEFINITIONS_FILE_NAME);
                implementationFilePath = path.join(innerMessagesDirectory, GenerateMessages.MESSAGES_IMPLEMENTATION_FILE_NAME);
            }
            else {
                interfaceFilePath = path.join(outerMessagesDirectory, GenerateMessages.MESSAGES_DEFINITIONS_FILE_NAME);
                implementationFilePath = path.join(outerMessagesDirectory, GenerateMessages.MESSAGES_IMPLEMENTATION_FILE_NAME);
            }
            _this.$fs.writeFile(interfaceFilePath, result.interfaceFile).wait();
            _this.$fs.writeFile(implementationFilePath, result.implementationFile).wait();
        }).future()();
    };
    GenerateMessages.MESSAGES_DEFINITIONS_FILE_NAME = "messages.d.ts";
    GenerateMessages.MESSAGES_IMPLEMENTATION_FILE_NAME = "messages.ts";
    return GenerateMessages;
})();
exports.GenerateMessages = GenerateMessages;
$injector.registerCommand("dev-generate-messages", GenerateMessages);
