git-project-manager/cmd/config_show.go

40 lines
845 B
Go
Raw Normal View History

2023-12-20 16:26:29 +00:00
package cmd
import (
"os"
"strings"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"
)
var configShowCmd = &cobra.Command{
Use: "show",
2024-12-27 22:42:44 +00:00
Short: "Show Git Project Manager Configuration",
2023-12-20 16:26:29 +00:00
Aliases: []string{"s", "dump", "cat", "ls"},
Run: runConfigShowCmd,
}
func runConfigShowCmd(cmd *cobra.Command, args []string) {
c := conf
2024-10-01 18:29:14 +00:00
showSensitive, _ := cmd.Flags().GetBool(FlagSensitive)
2023-12-20 16:26:29 +00:00
if !showSensitive {
plog.Info("Sensitive fields hidden, do not use unreviewed as config")
2024-01-17 21:56:41 +00:00
for _, r := range c.Remotes {
r.Token = strings.Repeat("*", len(r.Token))
}
2023-12-20 16:26:29 +00:00
} else {
plog.Warn("Displaying sensitive fields!")
}
enc := yaml.NewEncoder(os.Stdout)
enc.SetIndent(2)
enc.Encode(c)
}
func init() {
configCmd.AddCommand(configShowCmd)
2024-10-01 18:29:14 +00:00
configShowCmd.Flags().BoolP(FlagSensitive, "s", false, "Set to show sensitive fields")
2023-12-20 16:26:29 +00:00
}