hay-kot / scaffold

A cookie cutter alternative with in-project scaffolding for generating components, controllers, or other common code patterns.
https://hay-kot.github.io/scaffold/
MIT License
63 stars 8 forks source link

feat: dynamic # of questions #126

Closed anthonychung14 closed 6 months ago

anthonychung14 commented 6 months ago

first of all. love this tool. using it at work and find it intuitive.

I would like to use this tool to generate an arbitrary number of fields to a protobuf message.

are you willing to take a PR to attempt to do so? figure it could also be useful for templating so that something like

{{ for i, v := range .Scaffold.questionList 
        v.type v.name = i
}}

is possible. thoughts?

hay-kot commented 6 months ago

I'm not sure how we can do this with the current implementation. I do plan to migrate to https://github.com/charmbracelet/huh and that might open up some possibilities.

It would be possible to use the https://github.com/charmbracelet/huh?tab=readme-ov-file#text and split each line as it's own property.

In the mean time you could take in a comma separated string in a regular text input and split it in the template to render them each out.

hay-kot commented 6 months ago

FYI #129 adds a new loop property that will implement the ask here. Basically, if loop is present we will keep showing the same question over and over again until an empty string is submitted. Then the variable in the template will give you an array of strings.

anthonychung14 commented 6 months ago

amazing! thank you. look forward to using it