"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OpenDeviceLogStreamCommand = void 0;
const yok_1 = require("../../yok");
class OpenDeviceLogStreamCommand {
    constructor($devicesService, $errors, $commandsService, $options, $deviceLogProvider, $loggingLevels, $iOSSimulatorLogProvider, $cleanupService) {
        this.$devicesService = $devicesService;
        this.$errors = $errors;
        this.$commandsService = $commandsService;
        this.$options = $options;
        this.$deviceLogProvider = $deviceLogProvider;
        this.$loggingLevels = $loggingLevels;
        this.allowedParameters = [];
        $iOSSimulatorLogProvider.setShouldDispose(false);
        $cleanupService.setShouldDispose(false);
    }
    async execute(args) {
        this.$deviceLogProvider.setLogLevel(this.$loggingLevels.full);
        await this.$devicesService.initialize({
            deviceId: this.$options.device,
            skipInferPlatform: true,
        });
        if (this.$devicesService.deviceCount > 1) {
            await this.$commandsService.tryExecuteCommand("device", []);
            this.$errors.failWithHelp(OpenDeviceLogStreamCommand.NOT_SPECIFIED_DEVICE_ERROR_MESSAGE);
        }
        const action = (device) => device.openDeviceLogStream();
        await this.$devicesService.execute(action);
    }
}
exports.OpenDeviceLogStreamCommand = OpenDeviceLogStreamCommand;
OpenDeviceLogStreamCommand.NOT_SPECIFIED_DEVICE_ERROR_MESSAGE = "More than one device found. Specify device explicitly.";
yok_1.injector.registerCommand(["device|log", "devices|log"], OpenDeviceLogStreamCommand);
