From 0987b4a03e1cf8c3b159a9c0f2d500efd2af0e7b Mon Sep 17 00:00:00 2001 From: Axel Hecht Date: Fri, 21 Jun 2024 13:03:27 +0200 Subject: [PATCH] Add --pyDantic to cli for Python and Pydantic preset --- modelina-cli/src/helpers/python.ts | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/modelina-cli/src/helpers/python.ts b/modelina-cli/src/helpers/python.ts index ec2aaa284d..d469ce66a4 100644 --- a/modelina-cli/src/helpers/python.ts +++ b/modelina-cli/src/helpers/python.ts @@ -1,7 +1,15 @@ -import { PythonFileGenerator } from "@asyncapi/modelina"; +import { Flags } from "@oclif/core"; +import { PYTHON_PYDANTIC_PRESET, PythonFileGenerator } from "@asyncapi/modelina"; import { BuilderReturnType } from "./generate"; -export const PythonOclifFlags = { } +export const PythonOclifFlags = { + pyDantic: Flags.boolean({ + description: 'Python specific, generate the Pydantic models.', + required: false, + default: false, + }), + + } /** * This function builds all the relevant information for the main generate command @@ -10,7 +18,13 @@ export const PythonOclifFlags = { } * @returns */ export function buildPythonGenerator(flags: any): BuilderReturnType { - const fileGenerator = new PythonFileGenerator(); + const {pyDantic} = flags; + const presets = []; + if (pyDantic) { + presets.push(PYTHON_PYDANTIC_PRESET); + } + + const fileGenerator = new PythonFileGenerator({presets}); const fileOptions = undefined; return { fileOptions,