initial commit
[squeep-indie-auther] / bin / cli-helper.js
diff --git a/bin/cli-helper.js b/bin/cli-helper.js
new file mode 100644 (file)
index 0000000..5f1a1a3
--- /dev/null
@@ -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