Melkeydev / go-blueprint

Go-blueprint allows users to spin up a quick Go project using a popular framework
MIT License
2.06k stars 141 forks source link

Adds support for advanced features to be chosen inside flags #184

Closed Marcellofabrizio closed 2 months ago

Marcellofabrizio commented 3 months ago

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

Problem/Feature

Implementation of #183

Description of Changes:

Checklist

PS: I'm new to Go, so I would appreciate constructive feedback 😄

Marcellofabrizio commented 2 months ago

Hey @briancbarrow, I really appreciate the feedback, I'll be working on those comments as soon as I can. Regarding the suggested command, what should be the expected output?

briancbarrow commented 2 months ago

Hey @briancbarrow, I really appreciate the feedback, I'll be working on those comments as soon as I can. Regarding the suggested command, what should be the expected output?

We should either change the code to accept it like

go-blueprint create --advanced true --feature htmx,githubaction

or like this (I think this will be easier to do).

go-blueprint create --advanced --feature htmx --feature githubaction
Marcellofabrizio commented 2 months ago

Hey @briancbarrow, I implemented the changes to print the correct command based on the new flags. Here's how it looks: image

I also addressed your other comments.

briancbarrow commented 2 months ago

Hey @briancbarrow, I implemented the changes to print the correct command based on the new flags. Here's how it looks: image

I also addressed your other comments.

Sorry again for the late reply. Things are looking good. I did notice that now the steps for getting the htmx stuff working/generated are not printing as expected. See my comment above for that. I'm also still not getting the right output. I'm still getting go-blueprint create --name my-proj --framework chi --driver mysql --advanced true instead of the advanced features broken out. Can you confirm on your side that you are getting what is expected?

Screen Shot 2024-03-05 at 9 11 05 PM
Marcellofabrizio commented 2 months ago
briancbarrow commented 2 months ago
  • @briancbarrow Yes, I can replicate this. You're getting go-blueprint create --name my-proj --framework chi --driver mysql --advanced true because my code is only handling the features added in flags, not the ones selected by the steps. I didn't consider this case when I added it. I'll change it to handle both cases.

No worries. I should have more time this week to review things faster when you get that changed.

Marcellofabrizio commented 2 months ago

Hey @briancbarrow, it was a pretty simple fix, all I had to do was apply the same logic we are doing to the other flags, which is setting the selected value to the flag after we select them.

for key, opt := range options.Advanced.Choices {
    project.AdvancedOptions[strings.ToLower(key)] = opt
    err := cmd.Flag("feature").Value.Set(strings.ToLower(key))
    if err != nil {
        log.Fatal("failed to set the feature flag value", err)
    }
}

This allows the values to be passed down to NonInteractiveCommand and be printed as expected.

Marcellofabrizio commented 2 months ago

@briancbarrow Thank you!

briancbarrow commented 2 months ago

Thank you for working on this @Marcellofabrizio !