do not show the password on screen
@@ -157,7 +157,7 @@ func (c *ctxCommand) showCommand(_ *kingpin.ParseContext) error {
c.showIfNotEmpty(" Description: %s\n", cfg.Description())
c.showIfNotEmpty(" Server URLs: %s\n", cfg.ServerURL())
c.showIfNotEmpty(" Username: %s\n", cfg.User())
- c.showIfNotEmpty(" Password: %s\n", cfg.Password())
+ c.showIfNotEmpty(" Password: %s\n", cfg.Password(), "*********")
c.showIfNotEmpty(" Credentials: %s\n", cfg.Creds())
c.showIfNotEmpty(" NKey: %s\n", cfg.NKey())
c.showIfNotEmpty(" Certificate: %s\n", cfg.Certificate())
@@ -260,10 +260,15 @@ func (c *ctxCommand) selectCommand(pc *kingpin.ParseContext) error {
return c.showCommand(pc)
}
-func (c *ctxCommand) showIfNotEmpty(format string, arg string) {
- if arg == "" {
+func (c *ctxCommand) showIfNotEmpty(format string, arg ...string) {
+ if len(arg) == 0 || arg[0] == "" {
return
}
- fmt.Printf(format, arg)
+ if len(arg) == 2 {
+ fmt.Printf(format, arg[1])
+ return
+ }
+
+ fmt.Printf(format, arg[0])
}
