(programArgs: string[])
| 144 | } |
| 145 | } |
| 146 | async parse(programArgs: string[]) { |
| 147 | for (let i = 0; i < programArgs.length; i++) { |
| 148 | let arg = programArgs[i] |
| 149 | if ( |
| 150 | arg.startsWith("-") && |
| 151 | !this.pending && |
| 152 | // exclude positional parameters - addressess in negative workchains. |
| 153 | // Don't require 64 digits after ':', thus repeating parser behavior |
| 154 | // for addresses in positive working chains |
| 155 | /^-[0-9a-f]+:/.test(arg) === false |
| 156 | ) { |
| 157 | await this.parseOptionName(arg) |
| 158 | } else { |
| 159 | arg = arg.trim() |
| 160 | if (this.pending) { |
| 161 | await this.resolveValue(this.pending, arg) |
| 162 | } else if (this.controller && this.command) { |
| 163 | if ( |
| 164 | this.positional.length === 0 && |
| 165 | this.greedyArgument === undefined |
| 166 | ) { |
| 167 | throw new Error(`Unexpected argument ${arg}`) |
| 168 | } |
| 169 | if (this.positional[0]?.greedy) { |
| 170 | this.greedyArgument = this.positional[0] |
| 171 | } |
| 172 | await this.resolveValue( |
| 173 | this.positional[0] || this.greedyArgument, |
| 174 | arg, |
| 175 | ) |
| 176 | } else if (this.controller) { |
| 177 | const command = this.controller.commands.find(x => |
| 178 | matchName(x, arg), |
| 179 | ) |
| 180 | if (command) { |
| 181 | this.setCommand(command) |
| 182 | } else { |
| 183 | throw new Error(`Unknown command: ${arg}`) |
| 184 | } |
| 185 | } else { |
| 186 | this.controller = controllers.find(x => matchName(x, arg)) |
| 187 | if (!this.controller) { |
| 188 | const byAlias = findControllerAndCommandByAlias(arg) |
| 189 | if (byAlias) { |
| 190 | this.controller = byAlias.controller |
| 191 | this.setCommand(byAlias.command) |
| 192 | } else if (arg.toLowerCase().trim() === "info") { |
| 193 | this.printSummaryInfo = true |
| 194 | break |
| 195 | } else if (arg.toLowerCase().trim() === "update") { |
| 196 | this.updateEverdev = true |
| 197 | break |
| 198 | } else { |
| 199 | throw new Error(`Unknown tool: ${arg}.`) |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | } |
no test coverage detected