init

package
v0.0.0-...-93f7656 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InitCmd = &cobra.Command{
	Use:   "init <project_name>",
	Args:  cobra.MinimumNArgs(1),
	Short: "Init new project in current folder",
	RunE: func(_ *cobra.Command, args []string) error {
		_, err := exec.LookPath("gonew")
		if err != nil {
			return errors.New(`gonew not found, install it via "go install golang.org/x/tools/cmd/gonew@latest"`)
		}

		gonew := exec.Command(
			"gonew",
			"github.com/Kegian/agen/examples/server",
			args[0],
			".",
		)
		gonew.Stdout = os.Stdout
		gonew.Stderr = os.Stdout

		err = gonew.Run()
		if err != nil {
			return err
		}

		gotidy := exec.Command(
			"go", "mod", "tidy",
		)
		gotidy.Stdout = os.Stdout
		gotidy.Stderr = os.Stdout

		err = gotidy.Run()
		if err != nil {
			return err
		}

		fmt.Println()
		fmt.Println("Project successfully initialized!")
		fmt.Println()
		fmt.Println(">  make install -- Install required dependencies")
		fmt.Println(">  make gen     -- Generate api/sql go files")
		fmt.Println(">  make run     -- Run this project")

		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