(name, view, args)
| 1538 | } |
| 1539 | |
| 1540 | export function executeCommand(name, view, args) { |
| 1541 | const command = resolveCommand(name); |
| 1542 | if (!command) return false; |
| 1543 | const targetView = command.requiresView |
| 1544 | ? resolveView(view) |
| 1545 | : resolveView(view) || null; |
| 1546 | if (command.requiresView && !targetView) return false; |
| 1547 | if (!commandRunsInReadOnly(command, targetView)) return false; |
| 1548 | try { |
| 1549 | const result = command.run(targetView, args); |
| 1550 | return result !== false; |
| 1551 | } catch (error) { |
| 1552 | console.error(`Failed to execute command ${name}`, error); |
| 1553 | return false; |
| 1554 | } |
| 1555 | } |
| 1556 | |
| 1557 | export function getRegisteredCommands() { |
| 1558 | return Array.from(commandMap.values()).map((command) => ({ |
no test coverage detected