Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Main = gcmd.Command{ Name: "gf2-demo-cli", Brief: "A command-line tool demo", Description: "A command-line tool demo using GoFrame V2", Usage: "gf2-demo-cli [OPTION]", Examples: ` Dev: ./gf2-demo-cli Test: ./gf2-demo-cli -c config.test.yaml or GF_GCFG_FILE=config.test.yaml ./gf2-demo-cli Prod: ./gf2-demo-cli -c config.prod.yaml or GF_GCFG_FILE=config.prod.yaml ./gf2-demo-cli`, Additional: "Find more information at: https://github.com/windvalley/gf2-demo", Arguments: []gcmd.Argument{ { Name: "version", Short: "v", Brief: "print version info", IsArg: false, Orphan: true, }, { Name: "config", Short: "c", Brief: "config file (default config.yaml)", IsArg: false, Orphan: false, }, }, Func: func(ctx context.Context, parser *gcmd.Parser) (err error) { ver := parser.GetOpt("version") if ver != nil { utility.PrintVersionInfo() return nil } config := parser.GetOpt("config").String() if config != "" { g.Cfg().GetAdapter().(*gcfg.AdapterFile).SetFileName(config) } logFormat, err := g.Cfg().Get(ctx, "logger.cli.format") if err == nil { if logFormat.String() == "json" { glog.SetDefaultHandler(glog.HandlerJson) } } g.Log(consts.CliLoggerName).SetFlags(glog.F_TIME_STD | glog.F_FILE_LONG) configFile := g.Cfg().GetAdapter() g.Log(consts.CliLoggerName).Debugf(ctx, "use config file: %+v", configFile) g.Log(consts.CliLoggerName).Info(ctx, "foo") g.Log(consts.CliLoggerName).Error(ctx, errors.New("bar")) return nil }, } )
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.