File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ type Args = {
2+ [ name : string ] : string | true ;
3+ } ;
4+
15export 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}
You can’t perform that action at this time.
0 commit comments