From ff18f6ff9ee370f96039a207b98cd95433ef5424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Minelli?= <michael@minelli.me> Date: Tue, 3 Oct 2023 14:14:19 +0200 Subject: [PATCH] ExerciseRun => Add verbose mode (display compose output in live) --- NodeApp/src/commander/exercise/ExerciseRunCommand.ts | 11 ++++++++++- .../commander/session/App/SessionAppLoginCommand.ts | 2 +- .../session/Gitlab/SessionGitlabLoginCommand.ts | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/NodeApp/src/commander/exercise/ExerciseRunCommand.ts b/NodeApp/src/commander/exercise/ExerciseRunCommand.ts index 9eb4d8d..b5eec3e 100644 --- a/NodeApp/src/commander/exercise/ExerciseRunCommand.ts +++ b/NodeApp/src/commander/exercise/ExerciseRunCommand.ts @@ -36,6 +36,7 @@ class ExerciseRunCommand extends CommanderCommand { this.command .description('locally run an exercise') .option('-p, --path <value>', 'exercise path', Config.folders.defaultLocalExercise) + .option('-v, --verbose', 'exercise path', Config.folders.defaultLocalExercise) .action(this.commandAction.bind(this)); } @@ -46,7 +47,7 @@ class ExerciseRunCommand extends CommanderCommand { }).start().info(); } - protected async commandAction(options: any): Promise<void> { + protected async commandAction(options: { path: string, verbose: boolean }): Promise<void> { const localExercisePath = options.path ?? Config.folders.defaultLocalExercise; let assignmentFile: AssignmentFile; @@ -138,6 +139,14 @@ class ExerciseRunCommand extends CommanderCommand { await new Promise<void>((resolve, reject) => { let spinner: ora.Ora; + if ( options.verbose ) { + exerciseDockerCompose.events.on('logs', (log: string, _error: boolean, displayable: boolean) => { + if ( displayable ) { + console.log(log); + } + }); + } + exerciseDockerCompose.events.on('step', (name: string, message: string) => { spinner = ora({ text : message, diff --git a/NodeApp/src/commander/session/App/SessionAppLoginCommand.ts b/NodeApp/src/commander/session/App/SessionAppLoginCommand.ts index 514353f..58bc031 100644 --- a/NodeApp/src/commander/session/App/SessionAppLoginCommand.ts +++ b/NodeApp/src/commander/session/App/SessionAppLoginCommand.ts @@ -15,7 +15,7 @@ class SessionAppLoginCommand extends CommanderCommand { .action(this.commandAction.bind(this)); } - protected async commandAction(options: any): Promise<void> { + protected async commandAction(options: { user: string, password: string }): Promise<void> { if ( !options.password ) { options.password = (await inquirer.prompt({ type : 'password', diff --git a/NodeApp/src/commander/session/Gitlab/SessionGitlabLoginCommand.ts b/NodeApp/src/commander/session/Gitlab/SessionGitlabLoginCommand.ts index f7b156a..e76525e 100644 --- a/NodeApp/src/commander/session/Gitlab/SessionGitlabLoginCommand.ts +++ b/NodeApp/src/commander/session/Gitlab/SessionGitlabLoginCommand.ts @@ -14,7 +14,7 @@ class SessionGitlabLoginCommand extends CommanderCommand { .action(this.commandAction.bind(this)); } - protected async commandAction(options: any): Promise<void> { + protected async commandAction(options: { token: string }): Promise<void> { if ( !options.token ) { options.token = (await inquirer.prompt({ type : 'password', -- GitLab