...
This commit is contained in:
+19
-15
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user