MCPcopy Create free account
hub / github.com/MQEnergy/go-skeleton / Stack

Function Stack

cmd/cli/main.go:37–69  ·  view source on GitHub ↗

Stack 程序运行前的处理

()

Source from the content-addressed store, hash-verified

35
36// Stack 程序运行前的处理
37func Stack() *cli.App {
38 buildInfo := fmt.Sprintf("%s-%s-%s", runtime.GOOS, runtime.GOARCH, time.Now().Format(time.DateTime))
39
40 app := &cli.App{
41 Name: AppName,
42 Version: buildInfo,
43 Usage: AppUsage,
44 Authors: Authors,
45 }
46 app.Flags = []cli.Flag{
47 &cli.StringFlag{
48 Name: "env",
49 Aliases: []string{"e"},
50 Value: "dev",
51 Usage: "请选择配置文件 [dev | test | prod]",
52 Destination: &config.ConfEnv,
53 },
54 }
55 app.Commands = command.New().WithCommands()
56
57 app.Action = func(ctx *cli.Context) error {
58 fmt.Println(fmt.Sprintf("\u001B[34m%s\u001B[0m", _UI))
59 fmt.Println(`一、开发模式
60 1、执行 go run cmd/cli/main.go -h 查看命令集
61
62二、生产模式
63 1、make build 打包命令行工具
64 2、执行 ./releases/skeleton-cli -h 查看命令行
65`)
66 return nil
67 }
68 return app
69}
70
71func main() {
72 if err := Stack().Run(os.Args); err != nil {

Callers 1

mainFunction · 0.70

Calls 2

NewFunction · 0.92
WithCommandsMethod · 0.80

Tested by

no test coverage detected