cmd

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CreateCMD = &cobra.Command{
	Use:   "create",
	Short: "create a template project",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			log.Fatal("no arguments added... \n" +
				"Please add a name for you project.")
		}
		if len(args) > 1 {
			log.Fatal("too many arguments, only one argument supported")
		}
		_, err := os.ReadDir(args[0])

		if err != nil {
			log.Printf("No %v Dir, creating it now!\n", args[0])
			e := os.Mkdir(args[0], os.ModePerm)
			if e != nil {
				log.Fatal(e.Error())
			}
			e = os.Chdir(args[0])
			if e != nil {
				log.Fatal(e.Error())
			}
			CreateDirs()
			files, err := os.ReadDir(".")
			if err != nil {
				log.Fatal(err)
			}
			for _, file := range files {
				if file.IsDir() {
					createTemplate(file.Name())
				}
			}

			createMainFile(".")
			moduleName, err := cmd.Flags().GetString("module")
			if err != nil {
				log.Fatal(err)
			}
			InitProject(moduleName)
			InstallDependencies()
		} else {
			log.Println("Dir exists... do not need to create...")
		}
	},
}

create subCommand for ging_local

View Source
var RootCMD = &cobra.Command{
	Use:   "ging",
	Short: "ging is to create a gin dev template",
	Long: "This tool is built for those who are freshmen in gin, it will create a simple template which include " +
		"handlers, models, routers, templates and static directories. Besides, it will add some basic database connection configuration for users, some " +
		"simple handler functions and routers.",
	Run: func(cmd *cobra.Command, args []string) {},
}

Functions

func CreateDirs

func CreateDirs()

func Execute

func Execute()

func InitProject

func InitProject(modName string)

func InstallDependencies

func InstallDependencies()

Types

This section is empty.

Jump to

Keyboard shortcuts

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