git-bug/commands/bridge_auth_show.go

38 lines
753 B
Go
Raw Normal View History

2019-11-10 17:50:56 +03:00
package commands
import (
"fmt"
"time"
"github.com/spf13/cobra"
"github.com/MichaelMure/git-bug/bridge/core"
)
2019-11-10 19:32:14 +03:00
func runBridgeAuthShow(cmd *cobra.Command, args []string) error {
2019-11-10 17:50:56 +03:00
token, err := core.LoadTokenPrefix(repo, args[0])
if err != nil {
return err
}
fmt.Printf("Id: %s\n", token.ID())
fmt.Printf("Target: %s\n", token.Target)
2019-11-10 19:32:14 +03:00
fmt.Printf("Type: token\n")
fmt.Printf("Value: %s\n", token.Value)
2019-11-10 17:50:56 +03:00
fmt.Printf("Creation: %s\n", token.CreateTime.Format(time.RFC822))
return nil
}
2019-11-10 19:32:14 +03:00
var bridgeAuthShowCmd = &cobra.Command{
2019-11-10 17:50:56 +03:00
Use: "show",
2019-11-10 19:32:14 +03:00
Short: "Display an authentication credential.",
2019-11-10 17:50:56 +03:00
PreRunE: loadRepo,
2019-11-10 19:32:14 +03:00
RunE: runBridgeAuthShow,
2019-11-10 17:50:56 +03:00
Args: cobra.ExactArgs(1),
}
func init() {
2019-11-10 19:32:14 +03:00
bridgeAuthCmd.AddCommand(bridgeAuthShowCmd)
2019-11-10 17:50:56 +03:00
}