diff options
Diffstat (limited to 'commands/bridge_auth_show.go')
-rw-r--r-- | commands/bridge_auth_show.go | 32 |
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 } |