gime/cmd/config.go

38 lines
694 B
Go
Raw Normal View History

2022-01-19 18:56:31 +00:00
/*
2022-01-19 21:30:30 +00:00
Copyright © 2022 brian buller <brian@bullercodeworks.com>
2022-01-19 18:56:31 +00:00
*/
package cmd
import (
"fmt"
"sort"
2022-01-19 18:56:31 +00:00
"github.com/spf13/cobra"
"github.com/spf13/viper"
2022-01-19 18:56:31 +00:00
)
// configCmd represents the config command
var configCmd = &cobra.Command{
Use: "config",
Short: "Print all configuration values",
RunE: opConfig,
2022-01-19 18:56:31 +00:00
}
func init() {
rootCmd.AddCommand(configCmd)
2022-01-19 21:30:30 +00:00
}
2022-01-19 18:56:31 +00:00
2022-01-19 21:30:30 +00:00
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)
}
2022-01-19 21:30:30 +00:00
return nil
2022-01-19 18:56:31 +00:00
}