44 lines
728 B
Go
44 lines
728 B
Go
/*
|
|
Copyright © 2023 AGECEM
|
|
*/
|
|
package cmd
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"log"
|
|
|
|
"git.agecem.com/agecem/agecem-org/config"
|
|
"github.com/spf13/cobra"
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
// configCmd represents the config command
|
|
var configCmd = &cobra.Command{
|
|
Use: "config",
|
|
Short: "Print the config to stdout in indented JSON format",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
var cfg config.Config
|
|
|
|
if err := viper.Unmarshal(&cfg); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
printConfig(cfg)
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(configCmd)
|
|
}
|
|
|
|
func printConfig(config config.Config) error {
|
|
buf, err := json.MarshalIndent(config, "", " ")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
fmt.Println(string(buf))
|
|
|
|
return nil
|
|
}
|