"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ThrowingUserInputProvider = void 0;
const tslib_1 = require("tslib");
require("reflect-metadata");
const inversify_1 = require("inversify");
const core_1 = require("@oclif/core");
const codiac_common_1 = require("@codiac.io/codiac-common");
/** For use in a non-TTY scenario: Throws on any request for user interaction.
 */
let ThrowingUserInputProvider = class ThrowingUserInputProvider {
    /**
     *
     * @param logger
     * @param userMessageHandling Declares what to do with user messages (optional: defaults to `write`); `write`: write the message to stdout, `suppress`: do nothing, `throw` raise an exception describing that user messages are not permitted.
     */
    constructor(logger, userMessageHandling = "write") {
        this.logger = logger;
        this.userMessageHandling = userMessageHandling;
    }
    userMessage(message) {
        switch (this.userMessageHandling) {
            case "suppress":
                // Do nothing
                this.logger.notice(message);
                break;
            case "throw":
                throw new Error(`Cannot write user messages: this cli command disabled all user interaction.`);
            case "write":
            default:
                core_1.ux.log(message);
                break;
        }
    }
    prompt(id, prompt, required, defaultValue) {
        throw new Error(`Cannot acquire input [id: ${id}]: this cli command disabled all user input.`);
    }
    promptPassword(id, prompt) {
        throw new Error(`Cannot acquire input [id: ${id}]: this cli command disabled all user input.`);
    }
    promptSelect(id, prompt, choices, multiSelect, loop) {
        throw new Error(`Cannot acquire input [id: ${id}]: this cli command disabled all user input.`);
    }
    promptSelectMulti(id, prompt, choices, loop) {
        throw new Error(`Cannot acquire input [id: ${id}]: this cli command disabled all user input.`);
    }
    promptSelectFile(id, prompt, fileOptions) {
        throw new Error(`Cannot acquire input [id: ${id}]: this cli command disabled all user input.`);
    }
    promptSelectFolder(id, prompt, folderOptions) {
        throw new Error(`Cannot acquire input [id: ${id}]: this cli command disabled all user input.`);
    }
    promptConfirm(id, prompt, defaultValue) {
        throw new Error(`Cannot acquire input [id: ${id}]: this cli command disabled all user input.`);
    }
    openUrl(url) {
        throw new Error(`Cannot open browser window to url [${url}]: this cli command disabled all user input.`);
    }
    startSpinner(userMessage) {
        this.userMessage(userMessage);
    }
    stopSpinner(userMessage) {
        this.userMessage(userMessage);
    }
};
ThrowingUserInputProvider = tslib_1.__decorate([
    (0, inversify_1.injectable)(),
    tslib_1.__param(0, (0, inversify_1.inject)(codiac_common_1.INTERFACES.IBetterLogger)),
    tslib_1.__param(1, (0, inversify_1.unmanaged)()),
    tslib_1.__metadata("design:paramtypes", [Object, String])
], ThrowingUserInputProvider);
exports.ThrowingUserInputProvider = ThrowingUserInputProvider;
//# sourceMappingURL=throwing-user-input-provider.js.map