( command: string | null, positionals: string[], arg: string, )
| 298 | } |
| 299 | |
| 300 | function shouldTreatUnknownDashTokenAsPositional( |
| 301 | command: string | null, |
| 302 | positionals: string[], |
| 303 | arg: string, |
| 304 | ): boolean { |
| 305 | if (!isNegativeNumericToken(arg)) return false; |
| 306 | if (!command) return false; |
| 307 | const schema = getCommandSchema(command); |
| 308 | if (!schema) return true; |
| 309 | if (schema.allowsExtraPositionals) return true; |
| 310 | const positionalArgs = schema.positionalArgs ?? []; |
| 311 | if (positionalArgs.length === 0) return false; |
| 312 | if (positionals.length < positionalArgs.length) return true; |
| 313 | return positionalArgs.some((entry) => entry.includes('?')); |
| 314 | } |
| 315 | |
| 316 | function isNegativeNumericToken(value: string): boolean { |
| 317 | return /^-\d+(\.\d+)?$/.test(value); |
no test coverage detected