This commit is contained in:
mierenmanz 2021-04-28 20:29:27 +02:00
parent dcbf635860
commit bffead6680

View file

@ -15,7 +15,7 @@ export function parseArgs(
messageArgs: string[] messageArgs: string[]
): Record<string, unknown> | null { ): Record<string, unknown> | null {
if (commandArgs === undefined) return null if (commandArgs === undefined) return null
const messageArgsNullableCopy: Array<string | null> = [...messageArgs] const messageArgsNullableCopy: Array<string | null> = [...messageArgs]
const args: Record<string, unknown> = {} const args: Record<string, unknown> = {}
@ -48,7 +48,7 @@ function parseFlags(
argsNullable[i] = null argsNullable[i] = null
args[entry.name] = true args[entry.name] = true
break break
} else args[entry.name] = entry.defaultValue ?? false; } else args[entry.name] = entry.defaultValue ?? false
} }
} }
@ -81,5 +81,5 @@ function parseRest(
argsNullable: Array<string | null> argsNullable: Array<string | null>
): void { ): void {
const restValues = argsNullable.filter((x) => typeof x === 'string') const restValues = argsNullable.filter((x) => typeof x === 'string')
args[entry.name] = restValues !== null ? restValues : entry.defaultValue; args[entry.name] = restValues !== null ? restValues : entry.defaultValue
} }