A bit of refactoring and updates
All checks were successful
ci/woodpecker/push/build Pipeline was successful

Signed-off-by: Nikolai Rodionov <iam@allanger.xyz>
This commit is contained in:
2026-05-11 11:57:17 +02:00
parent 33f48f2bfb
commit 99f9bb462f
12 changed files with 270 additions and 678 deletions

38
cmd/root.go Normal file
View File

@@ -0,0 +1,38 @@
package cmd
import (
"context"
"errors"
"gitea.badhouseplants.net/softplayer/softplayer-backend/internal/helpers/logger"
"github.com/alecthomas/kong"
)
var CLI struct {
Server Server `cmd:"" help:"Start the grpc server"`
Migrate Migrate `cmd:"" help:"Run the database migrations"`
// Args
LogLevel string `env:"SOFTPLAYER_LOGLEVEL" default:"info"`
}
var ErrUnknownCommand = errors.New("unknown command")
func Run() error {
kongCtx := kong.Parse(&CLI)
ctx := logger.NewLogger(context.Background(), CLI.LogLevel)
switch kongCtx.Command() {
case "server":
if err := CLI.Server.Run(ctx); err != nil {
return err
}
case "migrate":
if err := CLI.Migrate.Run(ctx); err != nil {
return err
}
default:
return ErrUnknownCommand
}
return nil
}