Lint command parser

This commit is contained in:
TheEssem 2021-05-17 16:49:21 -05:00
parent b748e54437
commit c92b9a7b25
No known key found for this signature in database
GPG key ID: A3F9F02129092FCA

View file

@ -1,21 +1,19 @@
module.exports = (input) => {
input = input.split(" ");
let args = {_: []};
const args = { _: [] };
let curr = null;
let cont = false;
for (let i = 0; i < input.length; i++) {
const a = input[i];
if(a.startsWith('--')) {
if (a.startsWith("--")) {
if (curr) {
args[curr] = true;
}
args[a.slice(2)] = "";
curr = a.slice(2);
} else if (curr) {
if(a.startsWith('"')) {
args[curr] = a.slice(1)+" ";
} else if(a.endsWith('"')) {
if (a.startsWith("\"")) {
args[curr] = `${a.slice(1)} `;
} else if (a.endsWith("\"")) {
args[curr] += a.slice(0, -1);
curr = null;
} else {
@ -36,7 +34,7 @@ module.exports = (input) => {
}
return args;
}
};
// /*
// Format: