projectCmds

package
v0.6.10 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Copyright © 2023 Adharsh M dev@adharsh.in

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...")

		isGoModule := project.IsGoModule()
		isGitRepo := project.IsGitRepo()
		pkg := getPackageName(args)
		app := getAppNameFromPkgName(pkg)

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

		config := &project.Config{
			RootPath:     workdir,
			PkgName:      pkg,
			AppName:      app,
			ModName:      "ping",
			ExportedName: "Ping",
			IsGoModule:   isGoModule,
			IsGitRepo:    isGitRepo,
		}

		generator := project.NewGenerator(config)
		err = generator.GenerateProject()
		if err != nil {
			log.Fatal(err)
			return
		}

		log.Println("Project generated successfully.")
	},
}
View Source
var ModuleCmd = &cobra.Command{
	Use:   "module",
	Short: "Generate a module for project with gsk and clean architecture.",
	Args:  cobra.MinimumNArgs(1),
	Run: func(cmd *cobra.Command, args []string) {
		log.Println("Generating module files...")

		isGoModule := project.IsGoModule()
		isGitRepo := project.IsGitRepo()
		pkg := getPackageName(args)
		app := getAppNameFromPkgName(pkg)
		module := getModuleNameFromArgs(args)
		if module == "" {
			log.Fatal("Module name is required.")
			return
		}

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

		modConfig := &project.Config{
			RootPath:     workdir,
			PkgName:      pkg,
			AppName:      app,
			ModName:      module,
			ExportedName: strcase.ToCamel(module),
			IsGoModule:   isGoModule,
			IsGitRepo:    isGitRepo,
		}

		generator := project.NewGenerator(modConfig)
		err = generator.GenerateModule()
		if err != nil {
			log.Fatal(err)
			return
		}

		log.Println("Generated module files.")
	},
}

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