X-Git-Url: http://git.squeep.com/?p=squeep-indie-auther;a=blobdiff_plain;f=bin%2Fcli-helper.js;fp=bin%2Fcli-helper.js;h=5f1a1a3b73745cd44b94ccd6788cf715b7f844d0;hp=0000000000000000000000000000000000000000;hb=b0103b0d496262c438b40bc20304081dbfe41e73;hpb=8ed81748bce7cea7904cac7225b20a60cafdfc16 diff --git a/bin/cli-helper.js b/bin/cli-helper.js new file mode 100644 index 0000000..5f1a1a3 --- /dev/null +++ b/bin/cli-helper.js @@ -0,0 +1,38 @@ +'use strict'; + + +/** + * + * @param {String} option + * @returns {*} + */ +function getOption(option) { + let value; + while (process.argv.includes(option)) { + const optionIndex = process.argv.indexOf(option); + value = process.argv.splice(optionIndex, 2)[1]; + } + return value; +} + + +/** + * + * @param {String} flag + * @returns {Number} + */ +function getFlag(flag) { + let value = 0; + while (process.argv.includes(flag)) { + const flagIndex = process.argv.indexOf(flag); + process.argv.splice(flagIndex, 1); + value += 1; + } + return value; +} + + +module.exports = { + getFlag, + getOption, +}; \ No newline at end of file