Skip to content
Snippets Groups Projects
Commit 3a29dec8 authored by michael.minelli's avatar michael.minelli
Browse files

AssignmentCheckCommand => Add two levels of verbose

parent f4329f5e
No related branches found
No related tags found
No related merge requests found
Pipeline #28482 passed
......@@ -4,6 +4,7 @@ import ora from 'ora';
import chalk from 'chalk';
import AssignmentValidator from '../../../sharedByClients/helpers/Dojo/AssignmentValidator';
import ClientsSharedAssignmentHelper from '../../../sharedByClients/helpers/Dojo/ClientsSharedAssignmentHelper';
import { Option } from 'commander';
class AssignmentCheckCommand extends CommanderCommand {
......@@ -13,11 +14,15 @@ class AssignmentCheckCommand extends CommanderCommand {
this.command
.description('locally run a check of an assignment')
.option('-p, --path <value>', 'assignment path', Config.folders.defaultLocalExercise)
.option('-v, --verbose', 'verbose mode (display docker compose logs in live)')
.option('-v, --verbose', 'verbose mode - display principal container output in live')
.addOption(new Option('-w, --super-verbose', 'verbose mode - display all docker compose logs (build included) in live').conflicts('verbose'))
.addOption(new Option('--verbose-ssj2').hideHelp().implies({ superVerbose: true }))
.action(this.commandAction.bind(this));
}
protected async commandAction(options: { path: string, verbose: boolean }): Promise<void> {
protected async commandAction(options: { path: string, verbose: boolean, superVerbose: boolean }): Promise<void> {
const verbose: boolean = options.verbose || options.superVerbose;
const localExercisePath: string = options.path ?? Config.folders.defaultLocalExercise;
const assignmentValidator = new AssignmentValidator(localExercisePath);
......@@ -26,10 +31,17 @@ class AssignmentCheckCommand extends CommanderCommand {
await new Promise<void>((resolve, reject) => {
let spinner: ora.Ora;
if ( options.verbose ) {
assignmentValidator.events.on('logs', (log: string, _error: boolean, displayable: boolean) => {
if ( displayable ) {
console.log(log);
if ( verbose ) {
let buildPhase: boolean = true;
assignmentValidator.events.on('logs', (log: string, _error: boolean, displayable: boolean, _currentStep: string, currentSubStep: string) => {
for ( const line of log.split('\n') ) {
if ( currentSubStep == 'COMPOSE_RUN' && buildPhase && line != '' && !line.startsWith('#') ) {
buildPhase = false;
}
if ( displayable && (options.superVerbose || !buildPhase) ) {
console.log(line);
}
}
});
}
......@@ -44,14 +56,14 @@ class AssignmentCheckCommand extends CommanderCommand {
indent: 4
}).start();
if ( options.verbose && name == 'COMPOSE_RUN' ) {
if ( verbose && name == 'COMPOSE_RUN' ) {
spinner.info();
}
});
assignmentValidator.events.on('endSubStep', (stepName: string, message: string, error: boolean) => {
if ( error ) {
if ( options.verbose && stepName == 'COMPOSE_RUN' ) {
if ( verbose && stepName == 'COMPOSE_RUN' ) {
ora({
text : message,
indent: 4
......@@ -60,7 +72,7 @@ class AssignmentCheckCommand extends CommanderCommand {
spinner.fail(message);
}
} else {
if ( options.verbose && stepName == 'COMPOSE_RUN' ) {
if ( verbose && stepName == 'COMPOSE_RUN' ) {
ora({
text : message,
indent: 4
......
Subproject commit 04e9ad7c9f53fe47ffb2ef6f2c0266e28c1c963b
Subproject commit 68f6ffc241fabf4fd288871713419aab1d2d9f50
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment