@@ -40,23 +40,34 @@ var (
4040)
4141
4242func init () {
43- var flagFramework flags.Framework
43+ var flagBackend flags.Backend
4444 var flagDBDriver flags.Database
4545 var frontendFrameworks flags.FrontendFramework
4646 var frontendAdvanced flags.FrontendAdvanced
4747 var advancedFeatures flags.AdvancedFeatures
4848 var flagGit flags.Git
4949 rootCmd .AddCommand (createCmd )
5050
51+ // Main flags
5152 createCmd .Flags ().StringP ("name" , "n" , "" , "Name of project to create" )
52- createCmd .Flags ().VarP (& flagFramework , "framework " , "b" , fmt .Sprintf ("Framework to use. Allowed values: %s" , strings .Join (flags .AllowedProjectTypes , ", " )))
53+ createCmd .Flags ().VarP (& flagBackend , "backend " , "b" , fmt .Sprintf ("Backend to use. Allowed values: %s" , strings .Join (flags .AllowedBackedTypes , ", " )))
5354 createCmd .Flags ().VarP (& flagDBDriver , "driver" , "d" , fmt .Sprintf ("Database drivers to use. Allowed values: %s" , strings .Join (flags .AllowedDBDrivers , ", " )))
55+ createCmd .Flags ().VarP (& flagGit , "git" , "g" , fmt .Sprintf ("Git to use. Allowed values: %s" , strings .Join (flags .AllowedGitsOptions , ", " )))
56+
57+ // Frontend flags group
5458 createCmd .Flags ().BoolP ("frontend" , "f" , false , "Get prompts for frontend frameworks" )
5559 createCmd .Flags ().Var (& frontendFrameworks , "frontend-framework" , fmt .Sprintf ("Frontend framework to use. Allowed values: %s" , strings .Join (flags .AllowedFrontendTypes , ", " )))
5660 createCmd .Flags ().Var (& frontendAdvanced , "frontend-advanced" , fmt .Sprintf ("Frontend framework advanced features to use. Allowed values: %s" , strings .Join (flags .AllowedFrontendAdvanced , ", " )))
61+
62+ // Advanced features group
5763 createCmd .Flags ().BoolP ("advanced" , "a" , false , "Get prompts for advanced features" )
5864 createCmd .Flags ().Var (& advancedFeatures , "feature" , fmt .Sprintf ("Advanced feature to use. Allowed values: %s" , strings .Join (flags .AllowedAdvancedFeatures , ", " )))
59- createCmd .Flags ().VarP (& flagGit , "git" , "g" , fmt .Sprintf ("Git to use. Allowed values: %s" , strings .Join (flags .AllowedGitsOptions , ", " )))
65+
66+ // Mark dependencies for frontend flags
67+ createCmd .MarkFlagsRequiredTogether ("frontend" , "frontend-framework" )
68+
69+ // Mark feature flag as requiring --advanced
70+ createCmd .MarkFlagsRequiredTogether ("advanced" , "feature" )
6071}
6172
6273type Options struct {
@@ -95,7 +106,7 @@ var createCmd = &cobra.Command{
95106
96107 // VarP already validates the contents of the framework flag.
97108 // If this flag is filled, it is always valid
98- flagFramework := flags .Framework (cmd .Flag ("framework " ).Value .String ())
109+ flagBackend := flags .Backend (cmd .Flag ("backend " ).Value .String ())
99110 flagDBDriver := flags .Database (cmd .Flag ("driver" ).Value .String ())
100111 flagFrontendFremwork := flags .FrontendFramework (cmd .Flag ("frontend-framework" ).Value .String ())
101112 flagGit := flags .Git (cmd .Flag ("git" ).Value .String ())
@@ -116,17 +127,17 @@ var createCmd = &cobra.Command{
116127
117128 project := & program.Project {
118129 ProjectName : flagName ,
119- ProjectType : flagFramework ,
130+ ProjectType : flagBackend ,
120131 DBDriver : flagDBDriver ,
121- FrameworkMap : make (map [flags.Framework ]program.Framework ),
132+ BackendMap : make (map [flags.Backend ]program.Backend ),
122133 DBDriverMap : make (map [flags.Database ]program.Driver ),
123134 FrontendFramework : flagFrontendFremwork ,
124135 FrontendOptions : make (map [string ]bool ),
125136 AdvancedOptions : make (map [string ]bool ),
126137 GitOptions : flagGit ,
127138 }
128139
129- steps := steps .InitSteps (flagFramework , flagDBDriver , flagFrontendFremwork , flagGit )
140+ steps := steps .InitSteps (flagBackend , flagDBDriver , flagFrontendFremwork , flagGit )
130141 fmt .Printf ("%s\n " , logoStyle .Render (logo ))
131142
132143 // Advanced option steps:
@@ -177,7 +188,7 @@ var createCmd = &cobra.Command{
177188
178189 if project .ProjectType == "" {
179190 isInteractive = true
180- step := steps .Steps ["framework " ]
191+ step := steps .Steps ["backend " ]
181192 tprogram = tea .NewProgram (multiInput .InitialModelMulti (step .Options , options .ProjectType , step .Headers , project ))
182193 if _ , err := tprogram .Run (); err != nil {
183194 cobra .CheckErr (textinput .CreateErrorInputModel (err ).Err ())
@@ -187,11 +198,11 @@ var createCmd = &cobra.Command{
187198 step .Field = options .ProjectType .Choice
188199
189200 // this type casting is always safe since the user interface can
190- // only pass strings that can be cast to a flags.Framework instance
191- project .ProjectType = flags .Framework (strings .ToLower (options .ProjectType .Choice ))
192- err := cmd .Flag ("framework " ).Value .Set (project .ProjectType .String ())
201+ // only pass strings that can be cast to a flags.Backend instance
202+ project .ProjectType = flags .Backend (strings .ToLower (options .ProjectType .Choice ))
203+ err := cmd .Flag ("backend " ).Value .Set (project .ProjectType .String ())
193204 if err != nil {
194- log .Fatal ("failed to set the framework flag value" , err )
205+ log .Fatal ("failed to set the backend flag value" , err )
195206 }
196207 }
197208
@@ -357,13 +368,13 @@ var createCmd = &cobra.Command{
357368 }
358369
359370 if options .FrontendAdvanced .Choices ["Tailwind" ] && options .FrontendFramework .Choice == "Htmx" {
360- fmt .Println (endingMsgStyle .Render ("• Download the tailwind standalone cli wiht Makefile target\n " ))
371+ fmt .Println (endingMsgStyle .Render ("• Download the tailwind standalone cli with Makefile target\n " ))
361372 fmt .Println (endingMsgStyle .Render ("• More info about the Tailwind CLI: https://tailwindcss.com/blog/standalone-cli\n " ))
362373 }
363374
364375 if options .FrontendFramework .Choice == "Htmx" {
365- fmt .Println (endingMsgStyle .Render ("• Install the templ cli `go install github.com/a-h/templ/cmd/templ@latest` or use Makefile \n " ))
366- fmt .Println (endingMsgStyle .Render ("• Generate templ function files by running `templ generate`\n " ))
376+ fmt .Println (endingMsgStyle .Render ("• Install the templ cli `go install github.com/a-h/templ/cmd/templ@latest`\n " ))
377+ fmt .Println (endingMsgStyle .Render ("• Generate templ function files by running `templ generate` or use Makefile for both steps \n " ))
367378 }
368379
369380 if isInteractive {
0 commit comments