added cli argument parser
This commit is contained in:
parent
2139b0b111
commit
4aa965fece
1 changed files with 25 additions and 0 deletions
25
libs/cli.js
Normal file
25
libs/cli.js
Normal file
|
@ -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
|
||||||
|
};
|
Loading…
Reference in a new issue