makecmd

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigCmd = &cobra.Command{
	Use:   "config [name]",
	Short: "Create a config in app/config",
	Args:  cobra.MaximumNArgs(1),
	RunE: func(cmd *cobra.Command, args []string) error {
		var name string

		if len(args) > 0 {
			name = args[0]
		} else {
			prompt := &survey.Input{
				Message: "Config name:",
			}

			if err := survey.AskOne(prompt, &name, survey.WithValidator(survey.Required)); err != nil {
				return err
			}
		}

		if err := config.Create(name); err != nil {
			return err
		}

		fmt.Println("✔ config created:", name)
		fmt.Println()
		fmt.Println("Don't forget to register it in app/config/module.go:")
		fmt.Println()
		fmt.Printf("    fx.Provide(New%sCfg),\n", config.Title(name))

		return nil
	},
}
View Source
var ModelCmd = &cobra.Command{
	Use:  "model [name]",
	Args: cobra.MaximumNArgs(1),
	RunE: func(cmd *cobra.Command, args []string) error {
		var name string

		if len(args) > 0 {
			name = args[0]
		} else {
			prompt := &survey.Input{
				Message: "Model name:",
			}

			if err := survey.AskOne(prompt, &name, survey.WithValidator(survey.Required)); err != nil {
				return err
			}
		}

		if err := model.Create(name); err != nil {
			return err
		}

		fmt.Println("✔ model created:", name)
		fmt.Println()
		fmt.Println("Don't forget to generate ent code")
		fmt.Println()
		fmt.Println("  crew gen ent")
		fmt.Println()

		return nil
	},
}
View Source
var ModuleCmd = &cobra.Command{
	Use:  "module [name]",
	Args: cobra.MaximumNArgs(1),
	RunE: func(cmd *cobra.Command, args []string) error {
		var name string

		if len(args) > 0 {
			name = args[0]
		} else {
			prompt := &survey.Input{
				Message: "Module name:",
			}

			if err := survey.AskOne(prompt, &name, survey.WithValidator(survey.Required)); err != nil {
				return err
			}
		}

		if err := module.Create(name); err != nil {
			return err
		}

		fmt.Println("✔ module created:", name)
		fmt.Println()
		fmt.Println("Don't forget to register it in internal/modules/module.go:")
		fmt.Println()
		fmt.Printf(`    import "internal/modules/%s"

    fx.Options(
        %s.Module,
    )
`, name, name)

		return nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL