command

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2020 License: MIT Imports: 19 Imported by: 1

Documentation

Index

Constants

View Source
const (
	LogPrefix      = "[ardan] "
	RepositoryName = "Repository"
	ServiceName    = "Service"
	ControllerName = "Controller"
)

Variables

View Source
var (
	Setting          *setting.Setting
	ErrGoModNone     = errors.New("please use `go mod init` or use `--mod` global options\n")
	ErrDBConnStrNone = errors.New("please use `--db-conn` options or `config.yml` file setting database connection string\n")
)
View Source
var Gen = &cli.Command{
	Name:    "generate",
	Aliases: []string{"gen", "g"},
	Usage:   "generate source codes",
	Action: func(c *cli.Context) error {
		return cli.ShowSubcommandHelp(c)
	},
	Subcommands: []*cli.Command{
		GenAll,
		GenQuery,
		GenRepository,
		GenService,
		GenController,
	},
}

Gen sync database tabels struct

View Source
var GenAll = &cli.Command{
	Name:    "all",
	Aliases: []string{"a"},
	Usage:   "generate model all source codes",
	Action:  genAll,
}

GenAll gen all codes

View Source
var GenController = &cli.Command{
	Name:    "controller",
	Aliases: []string{"ctrl"},
	Usage:   "generate controller source codes",
	Action:  genController,
}

GenController gen controller

View Source
var GenQuery = &cli.Command{
	Name:    "query",
	Aliases: []string{"q"},
	Usage:   "generate model query source codes",
	Action:  genQuery,
}

GenQuery gen model query

View Source
var GenRepository = &cli.Command{
	Name:    "repository",
	Aliases: []string{"repo"},
	Usage:   "generate repository source codes",
	Action:  genRepo,
}

GenRepository gen repository

View Source
var GenService = &cli.Command{
	Name:    "service",
	Aliases: []string{"svc"},
	Usage:   "generate service source codes",
	Action:  genService,
}

GenService gen service

View Source
var Init = &cli.Command{
	Name:    "init",
	Aliases: []string{"i"},
	Usage:   "initial project layout",
	Action: func(c *cli.Context) error {
		return cli.ShowSubcommandHelp(c)
	},
	Subcommands: []*cli.Command{
		InitAll,
		InitLayout,
		InitApp,
		InitCmd,
		InitDoc,
		InitServer,
	},
}

Init init project layout

View Source
var InitAll = &cli.Command{
	Name:    "all",
	Aliases: []string{"a"},
	Usage:   "initial project layout & infrastructure codes",
	Action:  initAll,
}

InitAll initial application project layout & infrastructure codes

View Source
var InitApp = &cli.Command{
	Name:   "app",
	Usage:  "initial application layer infrastructure codes",
	Action: initAppCode,
}

InitApp init application layer infrastructure codes

View Source
var InitCmd = &cli.Command{
	Name:   "cmd",
	Usage:  "initial executed command layer infrastructure codes",
	Action: initCmdCode,
}

InitCmd init command layer infrastructure codes

View Source
var InitDoc = &cli.Command{
	Name:   "doc",
	Usage:  "initial document infrastructure codes",
	Action: initDocCode,
}

InitDoc init document infrastructure codes

View Source
var InitLayout = &cli.Command{
	Name:    "layout",
	Aliases: []string{"l"},
	Usage:   "initial project layout",
	Action:  initLayout,
}

InitLayout initial application project layout

View Source
var InitServer = &cli.Command{
	Name:    "server",
	Aliases: []string{"s"},
	Usage:   "initial server layer infrastructure codes",
	Action:  initServerCode,
}

InitServer init server layer infrastructure codes

View Source
var NewCmd = &cli.Command{
	Name:    "new",
	Aliases: []string{"n"},
	Usage:   "new item",
	Action: func(c *cli.Context) error {
		fmt.Println("new command")
		return nil
	},
	Subcommands: []*cli.Command{

		{
			Name:     "model",
			Usage:    "create application model",
			Category: "app",
			Action: func(c *cli.Context) error {
				fmt.Println("new model command")
				return nil
			},
		},

		{
			Name:     "repository",
			Aliases:  []string{"repo"},
			Usage:    "generate application repository",
			Category: "app",
			Action: func(c *cli.Context) error {
				fmt.Println("app repository command")
				return nil

			},
		},

		{
			Name:     "service",
			Aliases:  []string{"svc"},
			Usage:    "generate application service",
			Category: "app",
			Action: func(c *cli.Context) error {
				fmt.Println("app service command")
				return nil

			},
		},

		{
			Name:     "controller",
			Aliases:  []string{"ctrl"},
			Usage:    "generate server controller",
			Category: "server",
			Action: func(c *cli.Context) error {
				fmt.Println("server controller command")
				return nil

			},
		},

		{
			Name:     "module",
			Aliases:  []string{"mod", "modu"},
			Usage:    "generate server module",
			Category: "server",
			Action: func(c *cli.Context) error {
				fmt.Println("server module command")
				return nil

			},
		},

		{
			Name:     "middleware",
			Aliases:  []string{"mdw", "mid"},
			Usage:    "generate server middleware",
			Category: "server",
			Action: func(c *cli.Context) error {
				fmt.Println("server middleware command")
				return nil

			},
		},
	},
}

New application command

View Source
var Sync = &cli.Command{
	Name:    "sync",
	Aliases: []string{"s"},
	Usage:   "sync to database",
	Action: func(c *cli.Context) error {
		var err error
		err = syncToDB(c)
		if err != nil {
			return err
		}
		return nil
	},
	Subcommands: []*cli.Command{
		SyncToDB,
	},
}

Sync sync database tabels struct

View Source
var SyncToDB = &cli.Command{
	Name:   "todb",
	Usage:  "sync domain model to database",
	Action: syncToDB,
}

SyncToDB

Functions

func GoBuild added in v0.1.9

func GoBuild(dir string, source string, name string) error

func GoRun added in v0.1.9

func GoRun(dir string, main string) (string, error)

func Render

func Render(fname string, tmplName string, data map[string]interface{}) error

func Run

func Run() error

Run command run

func Setup

func Setup(c *cli.Context) error

Types

type Model added in v0.1.9

type Model struct {
	Name      string
	Directive string
	Gen       setting.GenSet
	Struct    types.Struct
}

func ParseModelFiles added in v0.1.9

func ParseModelFiles(c *cli.Context, directive setting.Directive) ([]*Model, error)

Jump to

Keyboard shortcuts

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