(commands: ICommand[])
| 281 | } |
| 282 | |
| 283 | protected async executeCommands(commands: ICommand[]) { |
| 284 | try { |
| 285 | for (const command of commands) { |
| 286 | if (isObsidianCommand(command)) |
| 287 | this.executeObsidianCommand(command); |
| 288 | if (isUserScriptCommand(command)) |
| 289 | await this.executeUserScript(command); |
| 290 | if (isChoiceCommand(command)) |
| 291 | await this.executeChoice(command); |
| 292 | if (isWaitCommand(command)) { |
| 293 | await waitFor(command.time); |
| 294 | } |
| 295 | if (isNestedChoiceCommand(command)) { |
| 296 | await this.executeNestedChoice(command); |
| 297 | } |
| 298 | if (isEditorCommand(command)) { |
| 299 | await this.executeEditorCommand(command); |
| 300 | } |
| 301 | if (isAIAssistantCommand(command)) { |
| 302 | await this.executeAIAssistant(command); |
| 303 | } |
| 304 | if (isOpenFileCommand(command)) { |
| 305 | await this.executeOpenFile(command); |
| 306 | } |
| 307 | if (isConditionalCommand(command)) { |
| 308 | await this.executeConditional(command); |
| 309 | } |
| 310 | } |
| 311 | } catch (error) { |
| 312 | if ( |
| 313 | handleMacroAbort(error, { |
| 314 | logPrefix: "Macro execution aborted", |
| 315 | noticePrefix: "Macro execution aborted", |
| 316 | defaultReason: "Macro execution aborted", |
| 317 | }) |
| 318 | ) { |
| 319 | this.choiceExecutor.signalAbort?.(error); |
| 320 | return; |
| 321 | } |
| 322 | throw error; |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | // Slightly modified from Templater's user script engine: |
| 327 | // https://github.com/SilentVoid13/Templater/blob/master/src/UserTemplates/UserTemplateParser.ts |
no test coverage detected