weather-cli-nk_sm
Version:
cli for weather forecast
19 lines (18 loc) • 500 B
JavaScript
export function getArgs(args = []) {
let flag = '-';
const tempArr = [];
args.forEach(arg => {
if (arg[0] == '-') {
if (flag != '-')
tempArr.push([flag.slice(1), true]);
flag = arg;
}
else if (flag != '-') {
tempArr.push([flag.slice(1), arg]);
flag = '-';
}
});
if (flag != '-')
tempArr.push([flag.slice(1), true]);
return Object.fromEntries(tempArr);
}