refactor: enhance config handling and unify main entrypoint
Unify configuration parsing logic across entrypoints and clean up legacy script-side config paths.
This commit is contained in:
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -19,7 +20,18 @@ import (
|
||||
func main() {
|
||||
configureLog()
|
||||
|
||||
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)
|
||||
}
|
||||
@@ -86,7 +98,7 @@ func main() {
|
||||
log.Infof("Migración terminada. Tablas: %d, Errores: %d, Filas totales: %d", len(results), totalErrors, totalProcessed)
|
||||
|
||||
totalDuration := time.Since(startTime)
|
||||
log.Infof("=== Migration completed successfully! ===")
|
||||
// log.Infof("=== Migration completed successfully! ===")
|
||||
log.Infof("Total migration time: %v", totalDuration)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user