Skip to content

Commit d14c764

Browse files
committed
chore: cleaned up generate code to private funcs are private
Signed-off-by: Kris Coleman <kriscodeman@gmail.com>
1 parent c8b9d6f commit d14c764

1 file changed

Lines changed: 34 additions & 34 deletions

File tree

cmd/generate.go

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,32 @@ import (
1515
"github.com/spf13/cobra"
1616
)
1717

18+
func GetGenerateCmd() *cobra.Command {
19+
generateCmd := &cobra.Command{
20+
Use: "generate",
21+
Short: "Generate typesafe OpenFeature accessors.",
22+
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
23+
return initializeConfig(cmd, "generate")
24+
},
25+
RunE: func(cmd *cobra.Command, args []string) error {
26+
cmd.Println("Available generators:")
27+
return generators.DefaultManager.PrintGeneratorsTable()
28+
},
29+
}
30+
31+
// Add generate flags using the config package
32+
config.AddGenerateFlags(generateCmd)
33+
34+
// Add all registered generator commands
35+
for _, subCmd := range generators.DefaultManager.GetCommands() {
36+
generateCmd.AddCommand(subCmd)
37+
}
38+
39+
addStabilityInfo(generateCmd)
40+
41+
return generateCmd
42+
}
43+
1844
// addStabilityInfo adds stability information to the command's help template before "Usage:"
1945
func addStabilityInfo(cmd *cobra.Command) {
2046
// Only modify commands that have a stability annotation
@@ -38,7 +64,7 @@ func addStabilityInfo(cmd *cobra.Command) {
3864
}
3965
}
4066

41-
func GetGenerateNodeJSCmd() *cobra.Command {
67+
func getGenerateNodeJSCmd() *cobra.Command {
4268
nodeJSCmd := &cobra.Command{
4369
Use: "nodejs",
4470
Short: "Generate typesafe Node.js client.",
@@ -82,7 +108,7 @@ func GetGenerateNodeJSCmd() *cobra.Command {
82108
return nodeJSCmd
83109
}
84110

85-
func GetGenerateReactCmd() *cobra.Command {
111+
func getGenerateReactCmd() *cobra.Command {
86112
reactCmd := &cobra.Command{
87113
Use: "react",
88114
Short: "Generate typesafe React Hooks.",
@@ -126,7 +152,7 @@ func GetGenerateReactCmd() *cobra.Command {
126152
return reactCmd
127153
}
128154

129-
func GetGenerateCSharpCmd() *cobra.Command {
155+
func getGenerateCSharpCmd() *cobra.Command {
130156
csharpCmd := &cobra.Command{
131157
Use: "csharp",
132158
Short: "Generate typesafe C# client.",
@@ -176,7 +202,7 @@ func GetGenerateCSharpCmd() *cobra.Command {
176202
return csharpCmd
177203
}
178204

179-
func GetGenerateGoCmd() *cobra.Command {
205+
func getGenerateGoCmd() *cobra.Command {
180206
goCmd := &cobra.Command{
181207
Use: "go",
182208
Short: "Generate typesafe accessors for OpenFeature.",
@@ -270,35 +296,9 @@ func getGeneratePythonCmd() *cobra.Command {
270296

271297
func init() {
272298
// Register generators with the manager
273-
generators.DefaultManager.Register(GetGenerateReactCmd)
274-
generators.DefaultManager.Register(GetGenerateGoCmd)
275-
generators.DefaultManager.Register(GetGenerateNodeJSCmd)
299+
generators.DefaultManager.Register(getGenerateReactCmd)
300+
generators.DefaultManager.Register(getGenerateGoCmd)
301+
generators.DefaultManager.Register(getGenerateNodeJSCmd)
276302
generators.DefaultManager.Register(getGeneratePythonCmd)
277-
generators.DefaultManager.Register(GetGenerateCSharpCmd)
278-
}
279-
280-
func GetGenerateCmd() *cobra.Command {
281-
generateCmd := &cobra.Command{
282-
Use: "generate",
283-
Short: "Generate typesafe OpenFeature accessors.",
284-
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
285-
return initializeConfig(cmd, "generate")
286-
},
287-
RunE: func(cmd *cobra.Command, args []string) error {
288-
cmd.Println("Available generators:")
289-
return generators.DefaultManager.PrintGeneratorsTable()
290-
},
291-
}
292-
293-
// Add generate flags using the config package
294-
config.AddGenerateFlags(generateCmd)
295-
296-
// Add all registered generator commands
297-
for _, subCmd := range generators.DefaultManager.GetCommands() {
298-
generateCmd.AddCommand(subCmd)
299-
}
300-
301-
addStabilityInfo(generateCmd)
302-
303-
return generateCmd
303+
generators.DefaultManager.Register(getGenerateCSharpCmd)
304304
}

0 commit comments

Comments
 (0)