Generate a secondary constructor using FunSpec
mainWhile FunSpec is primarily for functions, you can use FunSpec.constructorBuilder() to define a secondary constructor. You define parameters and statements just as you would for a regular method. KotlinPoet will automatically place the constructor before methods in the generated output.
val flux = FunSpec.constructorBuilder()
.addParameter("greeting", String::class)
.addStatement("this.%N = %N", "greeting", "greeting")
.build()
val helloWorld = TypeSpec.classBuilder("HelloWorld")
.addProperty("greeting", String::class, KModifier.PRIVATE)
.addFunction(flux)
.build()