( tokens: ReadonlyArray<Token>, context: CommandContext )
| 970 | * Returns LeafResult if no subcommand detected, SubcommandResult otherwise. |
| 971 | */ |
| 972 | const scanCommandLevel = ( |
| 973 | tokens: ReadonlyArray<Token>, |
| 974 | context: CommandContext |
| 975 | ): LevelResult => { |
| 976 | const cursor = makeCursor(tokens) |
| 977 | const state = createParseState(context.flagRegistry) |
| 978 | |
| 979 | for (let token = cursor.take(); token; token = cursor.take()) { |
| 980 | if (isFlagToken(token)) { |
| 981 | processFlag(token, cursor, context, state) |
| 982 | continue |
| 983 | } |
| 984 | |
| 985 | if (token._tag === "Value") { |
| 986 | const subResult = processValue(token.value, cursor, context, state) |
| 987 | if (subResult) return subResult |
| 988 | } |
| 989 | } |
| 990 | |
| 991 | return toLeafResult(state) |
| 992 | } |
no test coverage detected