"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const inquirer_1 = require("inquirer");
class Input {
    async string(msg, options = {}) {
        let { value } = await inquirer_1.prompt({
            message: msg,
            name: 'value',
            validate: options.validate,
        });
        return value;
    }
    async number(msg, options = {}) {
        let { value } = await inquirer_1.prompt({
            message: msg,
            type: 'number',
            name: 'value',
            validate: (input) => {
                try {
                    let intVal = parseInt(input);
                    if (Number.isNaN(intVal)) {
                        return `Value must be a number`;
                    }
                    if (options.min && intVal < options.min) {
                        return `Value must be >= ${options.min}`;
                    }
                    if (options.max && intVal > options.max) {
                        return `Value must be < ${options.max}`;
                    }
                    // console.log('Value => ', intVal);
                    return true;
                }
                catch (err) {
                    return err.message || false;
                }
            }
        });
        return value;
    }
    async confirm(msg, defaultValue) {
        let { confirm } = await inquirer_1.prompt({
            message: msg,
            type: 'confirm',
            default: defaultValue,
            name: 'confirm',
        });
        return confirm;
    }
    async selectOne(msg, choices, defaultValue) {
        let { value } = await inquirer_1.prompt({
            message: msg,
            type: 'list',
            name: 'value',
            default: defaultValue,
            choices: choices
        });
        return value;
    }
    async list(msg, choices) {
        let { value } = await inquirer_1.prompt({
            message: msg,
            type: 'list',
            choices: choices,
            name: 'value',
        });
        return value;
    }
}
exports.Input = Input;
exports.input = new Input();
//# sourceMappingURL=input.js.map