Skip to content

Commit cd41a30

Browse files
committed
1 parent d73623a commit cd41a30

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

src/main.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1+
type Args = {
2+
[name: string]: string | true;
3+
};
4+
15
export function parseArgs(
26
command: string,
37
options: {
48
positionalArgumentName?: string;
59
prefix: string;
610
}
7-
) {
11+
): {
12+
name: string;
13+
args?: Args;
14+
} {
815
const initialRegex = new RegExp(
916
`^${options.prefix}([\-_a-zA-Z0-9]{1,32})(?: (.+))?$`
1017
);
@@ -13,9 +20,7 @@ export function parseArgs(
1320

1421
const [_fullCmd, commandName, argsString] = command.match(initialRegex)!;
1522

16-
const args: {
17-
[name: string]: string | boolean;
18-
} = {};
23+
const args: Args = {};
1924
if (argsString) {
2025
const argsMatch = argsString.matchAll(argRegex);
2126
let workingArgsString = argsString;
@@ -47,5 +52,5 @@ export function parseArgs(
4752
);
4853
}
4954

50-
return { commandName, args };
55+
return { name: commandName, args };
5156
}

0 commit comments

Comments
 (0)