2023-12-20 16:26:29 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"gopkg.in/yaml.v3"
|
2024-12-30 20:50:31 +00:00
|
|
|
|
|
|
|
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
|
2023-12-20 16:26:29 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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) {
|
2024-12-30 20:50:31 +00:00
|
|
|
c := *utils.Config()
|
2023-12-20 16:26:29 +00:00
|
|
|
|
2024-12-30 20:50:31 +00:00
|
|
|
showSensitive, _ := cmd.Flags().GetBool(util.FlagSensitive)
|
2023-12-20 16:26:29 +00:00
|
|
|
if !showSensitive {
|
2024-12-30 20:50:31 +00:00
|
|
|
utils.Logger().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 {
|
2024-12-30 20:50:31 +00:00
|
|
|
utils.Logger().Warn("Displaying sensitive fields!")
|
2023-12-20 16:26:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
enc := yaml.NewEncoder(os.Stdout)
|
|
|
|
enc.SetIndent(2)
|
|
|
|
enc.Encode(c)
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
2024-12-30 20:50:31 +00:00
|
|
|
configShowCmd.Flags().BoolP(util.FlagSensitive, "s", false, "Set to show sensitive fields")
|
2023-12-20 16:26:29 +00:00
|
|
|
}
|