make

package
v1.2.2 Latest Latest
Warning

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

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

Documentation

Overview

Package make implements the command to generate a new file

Package make implements the command to generate a new file

Package make implements the command to generate a new file

Package make implements the command to generate a new file

Package make implements the command to generate a new file

Package make implements the command to generate a new file

Package make implements the command to generate a new file

Package make implements the command to generate a new file

Index

Constants

This section is empty.

Variables

View Source
var HandlerCommand = &cobra.Command{
	Use:   "make:handler <name>",
	Short: "Make a new handler",
	Long:  "Make a new handler",
	Args: func(cmd *cobra.Command, args []string) error {
		if len(args) < 1 {
			return errors.New("requires a name argument")
		}

		regex := regexp.MustCompile(`^[a-zA-Z0-9_]+$`)
		if !regex.MatchString(args[0]) {
			return fmt.Errorf("invalid name: %s", args[0])
		}

		return nil
	},
	Run: runMakeHandlerCommand,
}

HandlerCommand is the command to generate a new handler

View Source
var MigrationCommand = &cobra.Command{
	Use:   "make:migration <name>",
	Short: "Make a new migration",
	Long:  "Make a new migration",
	Args: func(cmd *cobra.Command, args []string) error {
		if len(args) < 1 {
			return errors.New("requires a name argument")
		}

		regex := regexp.MustCompile(`^[a-zA-Z0-9_]+$`)
		if !regex.MatchString(args[0]) {
			return fmt.Errorf("invalid name: %s", args[0])
		}

		return nil
	},
	Run:     runMakeMigrationCommand,
	Example: `gig make:migration create_users_table`,
}

MigrationCommand is the command to generate a new migration

View Source
var ModelCommand = &cobra.Command{
	Use:   "make:model <name>",
	Short: "Make a new model",
	Long:  "Make a new model",
	Args: func(cmd *cobra.Command, args []string) error {
		if len(args) < 1 {
			return errors.New("requires a name argument")
		}

		regex := regexp.MustCompile(`^[a-zA-Z0-9_]+$`)
		if !regex.MatchString(args[0]) {
			return fmt.Errorf("invalid name: %s", args[0])
		}

		return nil
	},
	Run:     runMakeModelCommand,
	Example: `gig make:model user || gig make:model user_address`,
}

ModelCommand is the command to generate a new model

View Source
var ModuleCommand = &cobra.Command{
	Use:   "make:module <name>",
	Short: "Make a new module",
	Long:  "Make a new module",
	Args: func(cmd *cobra.Command, args []string) error {
		if len(args) < 1 {
			return errors.New("requires a name argument")
		}

		regex := regexp.MustCompile(`^[a-zA-Z0-9_]+$`)
		if !regex.MatchString(args[0]) {
			return fmt.Errorf("invalid name: %s", args[0])
		}

		return nil
	},
	Run: runMakeModuleCommand,
}

ModuleCommand is the command to generate a new module

View Source
var RepositoryCommand = &cobra.Command{
	Use:   "make:repository <name>",
	Short: "Make a new repository",
	Long:  "Make a new repository",
	Args: func(cmd *cobra.Command, args []string) error {
		if len(args) < 1 {
			return errors.New("requires a name argument")
		}

		regex := regexp.MustCompile(`^[a-zA-Z0-9_]+$`)
		if !regex.MatchString(args[0]) {
			return fmt.Errorf("invalid name: %s", args[0])
		}

		return nil
	},
	Run: runMakeRepositoryCommand,
}

RepositoryCommand is the command to generate a new repository

View Source
var RequestCommand = &cobra.Command{
	Use:   "make:request <name>",
	Short: "Make a new request",
	Long:  "Make a new request",
	Args: func(cmd *cobra.Command, args []string) error {
		if len(args) < 1 {
			return errors.New("requires a name argument")
		}

		regex := regexp.MustCompile(`^[a-zA-Z0-9_]+$`)
		if !regex.MatchString(args[0]) {
			return fmt.Errorf("invalid name: %s", args[0])
		}

		return nil
	},
	Run: runMakeRequestCommand,
}

RequestCommand is the command to generate a new request

View Source
var ResponseCommand = &cobra.Command{
	Use:   "make:response <name>",
	Short: "Make a new response",
	Long:  "Make a new response",
	Args: func(cmd *cobra.Command, args []string) error {
		if len(args) < 1 {
			return errors.New("requires a name argument")
		}

		regex := regexp.MustCompile(`^[a-zA-Z0-9_]+$`)
		if !regex.MatchString(args[0]) {
			return fmt.Errorf("invalid name: %s", args[0])
		}

		return nil
	},
	Run: runMakeResponseCommand,
}

ResponseCommand is the command to generate a new response

View Source
var ServiceCommand = &cobra.Command{
	Use:   "make:service <name>",
	Short: "Make a new service",
	Long:  "Make a new service",
	Args: func(cmd *cobra.Command, args []string) error {
		if len(args) < 1 {
			return errors.New("requires a name argument")
		}

		regex := regexp.MustCompile(`^[a-zA-Z0-9_]+$`)
		if !regex.MatchString(args[0]) {
			return fmt.Errorf("invalid name: %s", args[0])
		}

		return nil
	},
	Run: runMakeServiceCommand,
}

ServiceCommand is the command to generate a new service

Functions

func GenerateHandler

func GenerateHandler(handlerOpt HandlerOptions, args []string)

GenerateHandler is the function that will be executed when the command is called It will generate a new handler file based on the template The template will be parsed with the handlerData Accepts the name of the module as an argument

func GenerateMigration added in v1.2.0

func GenerateMigration(migrationOpt MigrationOptions, args []string)

GenerateMigration is function that will be called from another package Accept MigrationOptions and []string as an argument

func GenerateModel

func GenerateModel(modelOpt ModelOptions, args []string)

GenerateModel is function that will be called from another package Accept ModelOptions and []string as an argument

func GenerateModule

func GenerateModule(moduleOpt ModuleOptions, args []string)

GenerateModule is the function that will be executed when the command is called It will generate handler, model, repository, request, response, service files based on the template

func GenerateRepository

func GenerateRepository(repositoryOptions RepositoryOptions, args []string)

GenerateRepository is the function that wrap generateRepository and generateRepositoryInterface Accept RepositoryOptions as an argument

func GenerateRequest

func GenerateRequest(requestOpt RequestOptions, args []string)

GenerateRequest is the function that will be executed when the command is called It will generate a new request file based on the template The template will be parsed with the requestData Accepts the name of the module as an argument

func GenerateResponse

func GenerateResponse(responseOpt ResponseOptions, args []string)

GenerateResponse is the function that will be executed when the command is called It will generate a new response file based on the template The template will be parsed with the responseData Accepts the name of the module as an argument

func GenerateService

func GenerateService(serviceOpt ServiceOptions, args []string)

GenerateService is the function that will be executed when the command is called It will generate a new service file based on the template The template will be parsed with the serviceData Accepts the name of the module as an argument

Types

type HandlerOptions

type HandlerOptions struct {
	Module string
	CRUD   bool
}

handlerOptions is the options that will be parsed in the command

type MigrationOptions added in v1.2.0

type MigrationOptions struct {
	Path string
}

MigrationOptions is the options that will be parsed in the command

type ModelOptions

type ModelOptions struct {
	Module string
	Plain  bool
}

ModelOptions is the options that will be parsed in the command

type ModuleOptions

type ModuleOptions struct {
	CRUD bool
}

ModuleOptions is the options that will be parsed in the command

type RepositoryOptions

type RepositoryOptions struct {
	CRUD   bool
	Module string
	ORM    bool
}

repositoryOptions is the options that will be parsed in the command

type RequestOptions

type RequestOptions struct {
	Module string
}

requestOptions is the options that will be parsed in the command

type ResponseOptions

type ResponseOptions struct {
	Module string
	Plain  bool
}

responseOptions is the options that will be parsed in the command

type ServiceOptions

type ServiceOptions struct {
	Module string
	CRUD   bool
}

serviceOptions is the options that will be parsed in the command

Jump to

Keyboard shortcuts

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