initial commit
[squeep-indie-auther] / bin / cli-helper.js
1 'use strict';
2
3
4 /**
5 *
6 * @param {String} option
7 * @returns {*}
8 */
9 function getOption(option) {
10 let value;
11 while (process.argv.includes(option)) {
12 const optionIndex = process.argv.indexOf(option);
13 value = process.argv.splice(optionIndex, 2)[1];
14 }
15 return value;
16 }
17
18
19 /**
20 *
21 * @param {String} flag
22 * @returns {Number}
23 */
24 function getFlag(flag) {
25 let value = 0;
26 while (process.argv.includes(flag)) {
27 const flagIndex = process.argv.indexOf(flag);
28 process.argv.splice(flagIndex, 1);
29 value += 1;
30 }
31 return value;
32 }
33
34
35 module.exports = {
36 getFlag,
37 getOption,
38 };