obhavo-cli-uz
Version:
Ob-Havo korsatib beruvchi o'zbekcha cli
17 lines (16 loc) • 530 B
JavaScript
export const getArgs = (args) => {
const res = {};
const [executer, file, ...rest] = args;
rest.forEach((value, index, array) => {
if (value.charAt(0) == "-") {
if (index == array.length - 1) {
res[value.substring(1)] = true;
} else if (array[index + 1].charAt(0) != "-") {
res[value.substring(1)] = array[index + 1];
} else {
res[value.substring(1)] = true;
}
}
});
return res;
};