2019-10-06 22:28:10 +02:00
|
|
|
package serv
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
func cmdConfDump(cmd *cobra.Command, args []string) {
|
|
|
|
if len(args) != 1 {
|
|
|
|
cmd.Help()
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
fname := fmt.Sprintf("%s.%s", getConfigName(), args[0])
|
|
|
|
|
2019-10-28 06:48:04 +01:00
|
|
|
conf, err := initConf()
|
|
|
|
if err != nil {
|
2019-11-25 08:22:33 +01:00
|
|
|
errlog.Fatal().Err(err).Msg("failed to read config")
|
2019-10-06 22:28:10 +02:00
|
|
|
}
|
|
|
|
|
2019-10-28 06:48:04 +01:00
|
|
|
if err := conf.Viper.WriteConfigAs(fname); err != nil {
|
2019-11-25 08:22:33 +01:00
|
|
|
errlog.Fatal().Err(err).Send()
|
2019-10-06 22:28:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
logger.Info().Msgf("config dumped to ./%s", fname)
|
|
|
|
}
|