projectCmds

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Copyright © 2023 Adharsh M dev@adharsh.in

Index

Constants

This section is empty.

Variables

View Source
var GenerateCmd = &cobra.Command{
	Use:   "generate",
	Short: "Generate a project with gsk and clean architecture.",
	Args:  cobra.MaximumNArgs(1),
	Run: func(cmd *cobra.Command, args []string) {
		log.Println("Generating project files...")

		workdir := getWorkDirFromArg(args)
		err := openDirectory(workdir)
		if err != nil {
			log.Fatal(err)
			return
		}

		var pkg string

		packageNameFromGit, err := getRepoName()
		if err == nil && packageNameFromGit != "" {

			log.Println("using existing git repo name: ", packageNameFromGit)
			pkg = packageNameFromGit
		} else {
			pkg = viper.GetString("project.package")
			randomName := project.RandomName()
			if pkg == "" {
				pkg = randomName
			}
		}

		app := getAppNameFromPkgName(pkg)

		config := &project.Config{
			RootPath: workdir,
			PkgName:  pkg,
			AppName:  app,
		}

		err = project.Generate(config)
		if err != nil {
			log.Fatal(err)
			return
		}

		log.Println("Project generated successfully.")
	},
}

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