minecraft-utils-shared
Version:
Shared utils for Minecraft Bedrock / Forge development related utilities.
64 lines (60 loc) • 1.39 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
/**
* @file Minecraft Utils Shared - Enquirer
* @license Apache-2.0
* @author Markus@Bordihn.de (Markus Bordihn)
*/
const spaceBarHint = ' (toggle with space)';
/**
* @param {string} input
* @param {*} choice
* @param {*} scope
* @returns {string}
*/
const formatBoolean = (input, choice, scope) => {
choice.input = '';
choice.cursor = 0;
const {
noop,
success,
dark
} = scope.styles;
const check = () => choice.enabled ? success('true') + '\t' + dark(spaceBarHint) : noop('false') + '\t' + dark(spaceBarHint);
if (input !== ' ') {
scope.alert();
return check();
}
choice.enabled = !choice.enabled;
return check();
};
/**
* @param {string} input
* @param {*} choice
* @param {*} scope
* @returns {string}
*/
const formatOptional = (input, choice, scope) => {
choice.input = '';
choice.cursor = 0;
const {
noop,
success,
dark
} = scope.styles;
const check = () => choice.enabled ? success('true') + ' 🏷️\t ' + dark(spaceBarHint) : noop('false') + ' 🏷️\t ' + dark(spaceBarHint);
if (input !== ' ') {
scope.alert();
return check();
}
choice.enabled = !choice.enabled;
return check();
};
var _default = {
formatBoolean,
formatOptional
};
exports.default = _default;