"use strict";
class RunCommandBase {
    constructor($platformService, $usbLiveSyncService, $options) {
        this.$platformService = $platformService;
        this.$usbLiveSyncService = $usbLiveSyncService;
        this.$options = $options;
    }
    executeCore(args) {
        if (this.$options.watch) {
            this.$platformService.deployPlatform(args[0]).wait();
            return this.$usbLiveSyncService.liveSync(args[0]);
        }
        else {
            return this.$platformService.runPlatform(args[0]);
        }
    }
}
exports.RunCommandBase = RunCommandBase;
class RunIosCommand extends RunCommandBase {
    constructor($platformService, $platformsData, $usbLiveSyncService, $options) {
        super($platformService, $usbLiveSyncService, $options);
        this.$platformsData = $platformsData;
        this.allowedParameters = [];
    }
    execute(args) {
        return this.executeCore([this.$platformsData.availablePlatforms.iOS]);
    }
}
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;
        }).future()();
    }
}
exports.RunAndroidCommand = RunAndroidCommand;
$injector.registerCommand("run|android", RunAndroidCommand);
