maps-service/pkg/cmds/root.go

38 lines
647 B
Go
Raw Normal View History

2024-11-26 23:30:58 +00:00
package cmds
2024-11-26 23:28:48 +00:00
import (
2024-11-26 23:30:58 +00:00
log "github.com/sirupsen/logrus"
2024-11-26 23:28:48 +00:00
"github.com/urfave/cli/v2"
"os"
"path/filepath"
)
var (
appName = filepath.Base(os.Args[0])
commonFlag = []cli.Flag{
&cli.BoolFlag{
Name: "debug",
Usage: "Enable debug logging",
2024-11-26 23:30:58 +00:00
Value: false,
Action: func(ctx *cli.Context, debug bool) error {
log.Println("ran")
if debug {
log.SetLevel(log.DebugLevel)
log.SetFormatter(&log.TextFormatter{})
log.SetReportCaller(false)
}
return nil
},
2024-11-26 23:28:48 +00:00
},
}
)
func NewApp() *cli.App {
app := cli.NewApp()
app.Name = appName
app.Usage = "Maps API Service"
app.Flags = commonFlag
return app
}