Skip to content

Commit

Permalink
feat: Add --pyDantic to cli for Python and Pydantic preset
Browse files Browse the repository at this point in the history
  • Loading branch information
Pike committed Jun 21, 2024
1 parent 3d2d085 commit 2120e09
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions modelina-cli/src/helpers/python.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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,
Expand Down

0 comments on commit 2120e09

Please sign in to comment.