This commit is contained in:
2026-07-23 18:19:29 +02:00
parent a67d060fc6
commit 4cd70eda33
2 changed files with 19 additions and 38 deletions
+19 -15
View File
@@ -107,25 +107,29 @@ export function parseCommand(input: string): ParsedCommand {
let pastEndOfOptions = false;
tokens.shift();
for (const token of tokens) {
if (token === "--") pastEndOfOptions = true;
for (let i = 1; i < tokens.length; i++) {
const token = tokens[i]!;
if (pastEndOfOptions) {
args.push(token);
} else {
if (token.startsWith("--")) {
flags.push(token.slice(2));
} else if (token.startsWith("-")) {
const newToken = token.slice(1);
const chars = newToken.split("");
for (const flag of chars) {
flags.push(flag);
}
} else {
args.push(token);
continue;
}
if (token === "--") {
pastEndOfOptions = true;
continue;
}
if (token.startsWith("--")) {
flags.push(token.slice(2));
continue;
} else if (token.startsWith("-")) {
for (const char of token.slice(1)) {
flags.push(char);
}
continue;
} else {
args.push(token);
continue;
}
}