main.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright 2025 BackendServerTemplate Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package v1
  5. import (
  6. "fmt"
  7. "github.com/SongZihuan/BackendServerTemplate/src/config"
  8. "github.com/SongZihuan/BackendServerTemplate/src/config/configparser"
  9. "github.com/SongZihuan/BackendServerTemplate/src/utils/exitutils"
  10. "github.com/spf13/cobra"
  11. )
  12. func MainV1(cmd *cobra.Command, args []string, inputConfigFilePath string, outputConfigFilePath string) (exitCode error) {
  13. var err error
  14. configProvider, err := configparser.NewProvider(inputConfigFilePath, &configparser.NewProviderOption{
  15. AutoReload: false,
  16. })
  17. if err != nil {
  18. return exitutils.SuccessExitSimple(fmt.Sprintf("Error: config file check failed: %s!", err.Error()))
  19. }
  20. err = config.InitConfig(&config.ConfigOption{
  21. ConfigFilePath: inputConfigFilePath,
  22. OutputFilePath: outputConfigFilePath,
  23. Provider: configProvider,
  24. })
  25. if err != nil {
  26. return exitutils.SuccessExitSimple(fmt.Sprintf("Error: config file check failed: %s!", err.Error()))
  27. }
  28. return exitutils.SuccessExitSimple("Info: config file check ok!")
  29. }