Lint command parser
This commit is contained in:
parent
b748e54437
commit
c92b9a7b25
1 changed files with 33 additions and 35 deletions
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue