commands

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Generator = cli.Command{
	Name:    "generate",
	Aliases: []string{"gen"},
	Subcommands: []*cli.Command{
		{
			Name:   "config",
			Usage:  "生成工具所需的配置文件",
			Action: actions.GenConfig,
			After: func(context *cli.Context) error {
				fmt.Println("配置文件已生成,注意修改项目对应值")
				return nil
			},
		},
		{
			Name:   "project",
			Usage:  "生成项目目录结构",
			Action: actions.GenProject,
		},
		{
			Name:   "db",
			Action: actions.GenDatabase,
			Usage:  "生成数据库相关文件",
		},
	},
	After: func(context *cli.Context) error {
		fmt.Println("开始执行go mod tidy...")

		command := exec.Command("go", "mod", "tidy")
		info, err := command.CombinedOutput()
		if err != nil {
			fmt.Println("执行go mod tidy错误", info)
			return err
		}
		fmt.Println("执行go mod tidy结束")
		return nil
	},
}

Generator 生成命令

View Source
var Test = cli.Command{
	Name:    "haha",
	Aliases: []string{"ha"},

	Usage:       "测试命令",
	UsageText:   "不要乱执行",
	Description: "jjj基尼太美基尼太美基尼太美基尼太美基尼太美基尼太美基尼太美基尼太美基尼太美",
	ArgsUsage:   "这是参数的描述",
	Category:    "test",
	BashComplete: func(context *cli.Context) {
		fmt.Println("????")
	},
	Before: func(context *cli.Context) error {
		fmt.Println("一级命令前置方法输出")
		return nil
	},
	After: func(context *cli.Context) error {
		fmt.Println("一级命令后置方法输出")
		return nil
	},
	OnUsageError: func(cCtx *cli.Context, err error, isSubcommand bool) error {
		fmt.Println("执行错误了", err, isSubcommand)
		return nil
	},
	Subcommands: []*cli.Command{
		{
			Name: "done",
			Action: func(context *cli.Context) error {
				fmt.Println("子命令")
				return nil
			},
			Usage: "测试命令子命令",
		},
	},
}

Test 测试命令

View Source
var Update = cli.Command{
	Name:    "update",
	Aliases: []string{"up"},
	Action: func(context *cli.Context) error {

		command := exec.Command("go", "install", "gitee.com/eddy87/gin-cli@latest")
		info, err := command.CombinedOutput()
		if err != nil {
			fmt.Println("升级出现问题", info)
			return err
		}
		fmt.Println("升级成功")
		return nil
	},
}

Update 生成命令

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
JackTT - Gopher 🇻🇳