git-project-manager/cmd/config_show.go
Ryan McGuire c78c41f567
All checks were successful
Build and Publish / release (push) Successful in 1m10s
Rename project to git-project-manager
2024-12-27 17:42:44 -05:00

40 lines
845 B
Go

package cmd
import (
"os"
"strings"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"
)
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 := conf
showSensitive, _ := cmd.Flags().GetBool(FlagSensitive)
if !showSensitive {
plog.Info("Sensitive fields hidden, do not use unreviewed as config")
for _, r := range c.Remotes {
r.Token = strings.Repeat("*", len(r.Token))
}
} 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(FlagSensitive, "s", false, "Set to show sensitive fields")
}