Primeiro Commit v0.beta1
This commit is contained in:
30
scripts/lib/cli-shared.mjs
Normal file
30
scripts/lib/cli-shared.mjs
Normal file
@@ -0,0 +1,30 @@
|
||||
export function parseArgs(argv) {
|
||||
const args = {};
|
||||
for (let index = 0; index < argv.length; index += 1) {
|
||||
const token = argv[index];
|
||||
if (!token.startsWith("--")) continue;
|
||||
const key = token.slice(2);
|
||||
const next = argv[index + 1];
|
||||
if (!next || next.startsWith("--")) {
|
||||
args[key] = "true";
|
||||
continue;
|
||||
}
|
||||
const valueParts = [next];
|
||||
let valueIndex = index + 2;
|
||||
while (valueIndex < argv.length && !argv[valueIndex].startsWith("--")) {
|
||||
valueParts.push(argv[valueIndex]);
|
||||
valueIndex += 1;
|
||||
}
|
||||
args[key] = valueParts.join(" ");
|
||||
index = valueIndex - 1;
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
export function splitCsv(value, fallback = []) {
|
||||
if (!value) return fallback;
|
||||
return value
|
||||
.split(",")
|
||||
.map((item) => item.trim())
|
||||
.filter(Boolean);
|
||||
}
|
||||
Reference in New Issue
Block a user