aboutsummaryrefslogtreecommitdiffstats
path: root/commands/bridge_auth_show.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-02-09 01:31:00 +0100
committerGitHub <noreply@github.com>2020-02-09 01:31:00 +0100
commit9e1a987b4d94dc5c2115423ede5954d4faf1d342 (patch)
treee30bb28d55444a7d1e66c8fa8b8ba7d413805473 /commands/bridge_auth_show.go
parent97bc5ccd229b7b438262a84e3c42783b4d4a82af (diff)
parent9b1aaa032d36e1ac05504916e359f767d1622d9d (diff)
downloadgit-bug-9e1a987b4d94dc5c2115423ede5954d4faf1d342.tar.gz
Merge pull request #294 from MichaelMure/cred-metadata
Cred metadata
Diffstat (limited to 'commands/bridge_auth_show.go')
-rw-r--r--commands/bridge_auth_show.go32
1 files changed, 12 insertions, 20 deletions
diff --git a/commands/bridge_auth_show.go b/commands/bridge_auth_show.go
index 02c56806..fbbf60a7 100644
--- a/commands/bridge_auth_show.go
+++ b/commands/bridge_auth_show.go
@@ -2,13 +2,14 @@ package commands
import (
"fmt"
+ "sort"
+ "strings"
"time"
"github.com/spf13/cobra"
"github.com/MichaelMure/git-bug/bridge/core/auth"
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/util/colors"
"github.com/MichaelMure/git-bug/util/interrupt"
)
@@ -25,28 +26,9 @@ func runBridgeAuthShow(cmd *cobra.Command, args []string) error {
return err
}
- var userFmt string
-
- switch cred.UserId() {
- case auth.DefaultUserId:
- userFmt = colors.Red("default user")
- default:
- user, err := backend.ResolveIdentity(cred.UserId())
- if err != nil {
- return err
- }
- userFmt = user.DisplayName()
-
- defaultUser, _ := backend.GetUserIdentity()
- if cred.UserId() == defaultUser.Id() {
- userFmt = colors.Red(userFmt)
- }
- }
-
fmt.Printf("Id: %s\n", cred.ID())
fmt.Printf("Target: %s\n", cred.Target())
fmt.Printf("Kind: %s\n", cred.Kind())
- fmt.Printf("User: %s\n", userFmt)
fmt.Printf("Creation: %s\n", cred.CreateTime().Format(time.RFC822))
switch cred := cred.(type) {
@@ -54,6 +36,16 @@ func runBridgeAuthShow(cmd *cobra.Command, args []string) error {
fmt.Printf("Value: %s\n", cred.Value)
}
+ fmt.Println("Metadata:")
+
+ meta := make([]string, 0, len(cred.Metadata()))
+ for key, value := range cred.Metadata() {
+ meta = append(meta, fmt.Sprintf(" %s --> %s\n", key, value))
+ }
+ sort.Strings(meta)
+
+ fmt.Print(strings.Join(meta, ""))
+
return nil
}