"use strict";
class RunCommandBase {
    constructor($platformService, $usbLiveSyncService, $options) {
        this.$platformService = $platformService;
        this.$usbLiveSyncService = $usbLiveSyncService;
        this.$options = $options;
    }
    executeCore(args) {
        this.$platformService.deployPlatform(args[0]).wait();
        if (this.$options.release) {
            return this.$platformService.runPlatform(args[0]);
        }
        return this.$usbLiveSyncService.liveSync(args[0]);
    }
}
exports.RunCommandBase = RunCommandBase;
class RunIosCommand extends RunCommandBase {
    constructor($platformService, $platformsData, $usbLiveSyncService, $options, $injector) {
        super($platformService, $usbLiveSyncService, $options);
        this.$platformsData = $platformsData;
        this.$injector = $injector;
        this.allowedParameters = [];
    }
    execute(args) {
        return this.executeCore([this.$platformsData.availablePlatforms.iOS]);
    }
    canExecute(args) {
        return (() => {
            return args.length === 0 && this.$platformService.validateOptions(this.$platformsData.availablePlatforms.iOS).wait();
        }).future()();
    }
}
exports.RunIosCommand = RunIosCommand;
$injector.registerCommand("run|ios", RunIosCommand);
class RunAndroidCommand extends RunCommandBase {
    constructor($platformService, $platformsData, $usbLiveSyncService, $options, $errors) {
        super($platformService, $usbLiveSyncService, $options);
        this.$platformsData = $platformsData;
        this.$errors = $errors;
        this.allowedParameters = [];
    }
    execute(args) {
        return this.executeCore([this.$platformsData.availablePlatforms.Android]);
    }
    canExecute(args) {
        return (() => {
            if (this.$options.release && (!this.$options.keyStorePath || !this.$options.keyStorePassword || !this.$options.keyStoreAlias || !this.$options.keyStoreAliasPassword)) {
                this.$errors.fail("When producing a release build, you need to specify all --key-store-* options.");
            }
            return args.length === 0 && this.$platformService.validateOptions(this.$platformsData.availablePlatforms.Android).wait();
        }).future()();
    }
}
exports.RunAndroidCommand = RunAndroidCommand;
$injector.registerCommand("run|android", RunAndroidCommand);
