( token: FlagToken, cursor: TokenCursor, context: CommandContext, state: ParseState )
| 890 | * Reports unrecognized flags as errors. |
| 891 | */ |
| 892 | const processFlag = ( |
| 893 | token: FlagToken, |
| 894 | cursor: TokenCursor, |
| 895 | context: CommandContext, |
| 896 | state: ParseState |
| 897 | ): void => { |
| 898 | const { commandPath, flagRegistry } = context |
| 899 | const resolved = resolveFlag(token, flagRegistry) |
| 900 | |
| 901 | if (!resolved) { |
| 902 | state.errors.push(createUnrecognizedFlagError(token, flagRegistry.params, commandPath)) |
| 903 | return |
| 904 | } |
| 905 | |
| 906 | const consumed = consumeFlagValue(cursor, token, resolved.param, resolved.negated) |
| 907 | if (consumed._tag === "Error") { |
| 908 | state.errors.push(consumed.error) |
| 909 | return |
| 910 | } |
| 911 | |
| 912 | state.flags.add(resolved.param.name, consumed.value) |
| 913 | } |
| 914 | |
| 915 | /** |
| 916 | * Processes a value token based on current parsing mode. |
no test coverage detected