From 4aa965fece4b1208c0cf680097a341b907b821d1 Mon Sep 17 00:00:00 2001 From: velvettear Date: Fri, 25 Feb 2022 15:41:27 +0100 Subject: [PATCH] added cli argument parser --- libs/cli.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 libs/cli.js diff --git a/libs/cli.js b/libs/cli.js new file mode 100644 index 0000000..244d1f1 --- /dev/null +++ b/libs/cli.js @@ -0,0 +1,25 @@ +const logger = require('./logger.js'); +const blinkstick = require('./blinkstick.js'); + +const ARG_CONFIG = '--config'; +const ARG_GET_SERIALS = '--get-blinksticks'; + +async function handleArguments() { + let handled = 0; + for (let index = 0; index < process.argv.length; index++) { + switch (process.argv[index]) { + case ARG_CONFIG: + continue; + case ARG_GET_SERIALS: + logger.info('blinksticks: ' + JSON.stringify(await blinkstick.findBlinkstick(blinkstick.ALL))); + handled++; + break; + } + } + return handled > 0; +} + +module.exports = { + handleArguments, + ARG_CONFIG +}; \ No newline at end of file