Files
public-api/pkg/cmds/root.go
2025-06-22 19:59:26 -04:00

38 lines
655 B
Go

package cmds
import (
log "github.com/sirupsen/logrus"
"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",
EnvVars: []string{"DEBUG"},
Value: false,
Action: func(ctx *cli.Context, debug bool) error {
if debug {
log.SetLevel(log.DebugLevel)
log.SetFormatter(&log.TextFormatter{})
log.SetReportCaller(false)
}
return nil
},
},
}
)
func NewApp() *cli.App {
app := cli.NewApp()
app.Name = appName
app.Usage = "Public api"
app.Flags = commonFlag
return app
}