diff --git a/modelina-cli/src/commands/generate.ts b/modelina-cli/src/commands/generate.ts index dd0be21383..92fb7f370a 100644 --- a/modelina-cli/src/commands/generate.ts +++ b/modelina-cli/src/commands/generate.ts @@ -32,6 +32,20 @@ export default class Models extends ModelinaCommand { }, } - await generateModels(flags, document, logger, language as Languages); + const generatedModels = await generateModels(flags, document, logger, language as Languages); + + if (flags.output) { + const generatedModelsString = generatedModels.map((model) => { return model.modelName; }); + logger.info(`Successfully generated the following models: ${generatedModelsString.join(', ')}`); + } else { + const generatedModelsString = generatedModels.map((model) => { + return `## Model name: ${model.modelName} +${model.result} +`; + }); + logger.info(`Successfully generated the following models: ${generatedModelsString.join('\n')}`); + } + + } } \ No newline at end of file diff --git a/modelina-cli/src/helpers/generate.ts b/modelina-cli/src/helpers/generate.ts index 0493a02569..f93a1f8d2b 100644 --- a/modelina-cli/src/helpers/generate.ts +++ b/modelina-cli/src/helpers/generate.ts @@ -110,23 +110,13 @@ export async function generateModels(flags: any, document: any, logger: any, lan const { fileGenerator, fileOptions } = mapper(flags); if (output) { - const models = await fileGenerator.generateToFiles( + return fileGenerator.generateToFiles( document, output, { ...fileOptions, }); - const generatedModels = models.map((model) => { return model.modelName; }); - logger.info(`Successfully generated the following models: ${generatedModels.join(', ')}`); - return; } - const models = await fileGenerator.generateCompleteModels( + return fileGenerator.generateCompleteModels( document, { ...fileOptions }); - const generatedModels = models.map((model) => { - return ` - ## Model name: ${model.modelName} - ${model.result} - `; - }); - logger.info(`Successfully generated the following models: ${generatedModels.join('\n')}`); } \ No newline at end of file