refactor: enhance config handling in main; unify config parsing logic across scripts

This commit is contained in:
2026-05-09 08:36:30 -05:00
parent 0c59d06af6
commit 8f8d2d11a4
2 changed files with 27 additions and 2 deletions

View File

@@ -1,6 +1,8 @@
package main
import (
"flag"
"git.ksdemosapps.com/kylesoda/go-migrate/internal/app/config"
log "github.com/sirupsen/logrus"
)
@@ -8,7 +10,18 @@ import (
func main() {
log.SetLevel(log.DebugLevel)
migrationConfig, err := config.ReadMigrationConfig()
configPath := flag.String("config", "", "path to migration config file")
flag.Parse()
if flag.NArg() > 1 {
log.Fatalf("only one config file path is allowed")
}
if *configPath == "" && flag.NArg() == 1 {
*configPath = flag.Arg(0)
}
migrationConfig, err := config.ReadMigrationConfig(*configPath)
if err != nil {
log.Fatalf("error leyendo configuracion: %v", err)
}