From 57baab825147324ba8a98f8f40048d7773415083 Mon Sep 17 00:00:00 2001 From: Ryan D McGuire Date: Wed, 20 Dec 2023 11:26:29 -0500 Subject: [PATCH] Add config show command --- cmd/config_show.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 cmd/config_show.go diff --git a/cmd/config_show.go b/cmd/config_show.go new file mode 100644 index 0000000..976865e --- /dev/null +++ b/cmd/config_show.go @@ -0,0 +1,37 @@ +package cmd + +import ( + "os" + "strings" + + "github.com/spf13/cobra" + "gopkg.in/yaml.v3" +) + +var configShowCmd = &cobra.Command{ + Use: "show", + Short: "Show GitLab Project Manager Configuration", + Aliases: []string{"s", "dump", "cat", "ls"}, + Run: runConfigShowCmd, +} + +func runConfigShowCmd(cmd *cobra.Command, args []string) { + c := conf + + showSensitive, _ := cmd.Flags().GetBool("sensitive") + if !showSensitive { + plog.Info("Sensitive fields hidden, do not use unreviewed as config") + c.GitlabToken = strings.Repeat("*", len(c.GitlabToken)) + } else { + plog.Warn("Displaying sensitive fields!") + } + + enc := yaml.NewEncoder(os.Stdout) + enc.SetIndent(2) + enc.Encode(c) +} + +func init() { + configCmd.AddCommand(configShowCmd) + configShowCmd.Flags().BoolP("sensitive", "s", false, "Set to show sensitive fields") +}