git-project-manager/cmd/config/config_show.go

41 lines
921 B
Go

package cmd
import (
"os"
"strings"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
)
var configShowCmd = &cobra.Command{
Use: "show",
Short: "Show Git Project Manager Configuration",
Aliases: []string{"s", "dump", "cat", "ls"},
Run: runConfigShowCmd,
}
func runConfigShowCmd(cmd *cobra.Command, args []string) {
c := *utils.Config()
showSensitive, _ := cmd.Flags().GetBool(util.FlagSensitive)
if !showSensitive {
utils.Logger().Info("Sensitive fields hidden, do not use unreviewed as config")
for _, r := range c.Remotes {
r.Token = strings.Repeat("*", len(r.Token))
}
} else {
utils.Logger().Warn("Displaying sensitive fields!")
}
enc := yaml.NewEncoder(os.Stdout)
enc.SetIndent(2)
enc.Encode(c)
}
func init() {
configShowCmd.Flags().BoolP(util.FlagSensitive, "s", false, "Set to show sensitive fields")
}