diff --git a/.changeset/hip-books-eat.md b/.changeset/hip-books-eat.md new file mode 100644 index 0000000000..2a3a4b1e9d --- /dev/null +++ b/.changeset/hip-books-eat.md @@ -0,0 +1,5 @@ +--- +'@finos/legend-application-pure-ide': patch +--- + +Introduce Pure IDE terminal debug command diff --git a/packages/legend-application-pure-ide/src/__lib__/LegendPureIDECommand.ts b/packages/legend-application-pure-ide/src/__lib__/LegendPureIDECommand.ts index af1b05dda9..5ba26b22fc 100644 --- a/packages/legend-application-pure-ide/src/__lib__/LegendPureIDECommand.ts +++ b/packages/legend-application-pure-ide/src/__lib__/LegendPureIDECommand.ts @@ -162,4 +162,5 @@ export enum LEGEND_PURE_IDE_TERMINAL_COMMAND { CLEAR = 'clear', ANSI = 'ansi', HELP = 'help', + DEBUG = 'debug', } diff --git a/packages/legend-application-pure-ide/src/stores/LegendPureIDETerminal.ts b/packages/legend-application-pure-ide/src/stores/LegendPureIDETerminal.ts index 264a88cf6d..c2e35abbf5 100644 --- a/packages/legend-application-pure-ide/src/stores/LegendPureIDETerminal.ts +++ b/packages/legend-application-pure-ide/src/stores/LegendPureIDETerminal.ts @@ -343,6 +343,18 @@ export const setupTerminal = (ideStore: PureIDEStore): void => { return Promise.resolve(); }, }, + { + command: LEGEND_PURE_IDE_TERMINAL_COMMAND.DEBUG, + description: + 'Introsptect debug state. When passing no parameters, will show display summary of available variables', + usage: 'debug [summary | abort | _expression_to_eval_]', + aliases: [], + handler: async (args: string[]): Promise => { + flowResult(ideStore.debugging({ args })).catch( + ideStore.applicationStore.alertUnhandledError, + ); + }, + }, { command: LEGEND_PURE_IDE_TERMINAL_COMMAND.HELP, description: 'Show help', diff --git a/packages/legend-application-pure-ide/src/stores/PureIDEStore.ts b/packages/legend-application-pure-ide/src/stores/PureIDEStore.ts index 484705f6db..64b2552278 100644 --- a/packages/legend-application-pure-ide/src/stores/PureIDEStore.ts +++ b/packages/legend-application-pure-ide/src/stores/PureIDEStore.ts @@ -196,6 +196,7 @@ export class PureIDEStore implements CommandRegistrar { loadFile: flow, execute: flow, executeGo: flow, + debugging: flow, manageExecuteGoResult: flow, executeTests: flow, executeFullTestSuite: flow, @@ -880,6 +881,24 @@ export class PureIDEStore implements CommandRegistrar { ); } + *debugging(command: { args: string[] }): GeneratorFn { + yield flowResult( + this.client + .execute([], 'debugging', command) + .then((r) => { + const execResult = deserializeExecutionResult( + guaranteeNonNullable(r), + ); + this.applicationStore.terminalService.terminal.output( + execResult.text!, + ); + }) + .catch((er) => { + this.applicationStore.terminalService.terminal.fail(er.message); + }), + ); + } + *manageExecuteGoResult( result: ExecutionResult, potentiallyAffectedFiles: string[],