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,25 +1,23 @@
module.exports = (input) => { module.exports = (input) => {
input = input.split(" "); input = input.split(" ");
let args = {_: []}; const args = { _: [] };
let curr = null; let curr = null;
let cont = false;
for (let i = 0; i < input.length; i++) { for (let i = 0; i < input.length; i++) {
const a = input[i]; const a = input[i];
if(a.startsWith('--')) { if (a.startsWith("--")) {
if(curr) { if (curr) {
args[curr] = true; args[curr] = true;
} }
args[a.slice(2)] = ""; args[a.slice(2)] = "";
curr = a.slice(2); curr = a.slice(2);
} else if(curr) { } else if (curr) {
if(a.startsWith('"')) { if (a.startsWith("\"")) {
args[curr] = a.slice(1)+" "; args[curr] = `${a.slice(1)} `;
} else if(a.endsWith('"')) { } else if (a.endsWith("\"")) {
args[curr] += a.slice(0, -1); args[curr] += a.slice(0, -1);
curr = null; curr = null;
} else { } else {
if(args[curr].split(" ").length == 1) { if (args[curr].split(" ").length == 1) {
args[curr] += a; args[curr] += a;
curr = null; curr = null;
} else { } else {
@ -31,12 +29,12 @@ module.exports = (input) => {
} }
} }
if(curr && args[curr] == "") { if (curr && args[curr] == "") {
args[curr] = true; args[curr] = true;
} }
return args; return args;
} };
// /* // /*
// Format: // Format: