gime/cmd/config.go

38 lines
694 B
Go

/*
Copyright © 2022 brian buller <brian@bullercodeworks.com>
*/
package cmd
import (
"fmt"
"sort"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
// configCmd represents the config command
var configCmd = &cobra.Command{
Use: "config",
Short: "Print all configuration values",
RunE: opConfig,
}
func init() {
rootCmd.AddCommand(configCmd)
}
func opConfig(cmd *cobra.Command, args []string) error {
var settings []string
for k, v := range viper.AllSettings() {
settings = append(settings, fmt.Sprintf("%s: %s", k, v))
}
sort.Strings(settings)
fmt.Println("Configuration File:", viper.ConfigFileUsed())
for _, v := range settings {
fmt.Println(v)
}
return nil
}