wrapper over numeric flag

This commit is contained in:
shashwat-runable
2026-04-30 07:16:02 +05:30
committed by cloudycotton
parent 3d3f83b48e
commit 47cf33a091
+1 -6
View File
@@ -10,11 +10,6 @@ interface FormatParseArgsErrorInput {
error: unknown
}
interface OptionalPositiveIntegerFlagInput {
name: string
value: unknown
}
const parseNumericFlag = ({ name, value }: NumericFlagInput) => {
if (typeof value !== "string") {
throw new Error(`Invalid value for --${name}: "${String(value)}". Expected a number.`)
@@ -26,7 +21,7 @@ const parseNumericFlag = ({ name, value }: NumericFlagInput) => {
return numeric
}
const parseOptionalPositiveIntegerFlag = ({ name, value }: OptionalPositiveIntegerFlagInput) => {
const parseOptionalPositiveIntegerFlag = ({ name, value }: NumericFlagInput) => {
if (value === undefined) return undefined
const numeric = parseNumericFlag({ name, value })
if (!Number.isInteger(numeric) || numeric <= 0) {