UNPKG

weather-cli-starter

Version:

Console interface for getting weather condition

18 lines (16 loc) 421 B
const getArgs = (args) => { const res = {}; const [_executor, _file, ...rest] = args; rest.forEach((value, index, array) => { if(value.charAt(0) === '-') { const nextArg = array[index + 1]?.charAt(0); if (nextArg && nextArg !== '-') { res[value.substring(1)] = array[index + 1]; } else { res[value.substring(1)] = true; } } }) return res; } export { getArgs };