( token: FlagToken, cursor: TokenCursor, context: CommandContext, state: ParseState )
| 855 | * Reports unrecognized flags as errors. |
| 856 | */ |
| 857 | const processFlag = ( |
| 858 | token: FlagToken, |
| 859 | cursor: TokenCursor, |
| 860 | context: CommandContext, |
| 861 | state: ParseState |
| 862 | ): void => { |
| 863 | const { commandPath, flagRegistry } = context |
| 864 | const resolved = resolveFlag(token, flagRegistry) |
| 865 | |
| 866 | if (!resolved) { |
| 867 | state.errors.push(createUnrecognizedFlagError(token, flagRegistry.params, commandPath)) |
| 868 | return |
| 869 | } |
| 870 | |
| 871 | const consumed = consumeFlagValue(cursor, token, resolved.param, resolved.negated) |
| 872 | if (consumed._tag === "Error") { |
| 873 | state.errors.push(consumed.error) |
| 874 | return |
| 875 | } |
| 876 | |
| 877 | state.flags.add(resolved.param.name, consumed.value) |
| 878 | } |
| 879 | |
| 880 | /** |
| 881 | * Processes a value token based on current parsing mode. |
no test coverage detected