2019-11-10 17:50:56 +03:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
2019-12-08 23:15:06 +03:00
|
|
|
"github.com/MichaelMure/git-bug/bridge/core/auth"
|
2019-11-10 17:50:56 +03:00
|
|
|
)
|
|
|
|
|
2019-11-10 19:32:14 +03:00
|
|
|
func runBridgeAuthShow(cmd *cobra.Command, args []string) error {
|
2019-12-08 23:15:06 +03:00
|
|
|
cred, err := auth.LoadWithPrefix(repo, args[0])
|
2019-11-10 17:50:56 +03:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-12-08 23:15:06 +03:00
|
|
|
fmt.Printf("Id: %s\n", cred.ID())
|
|
|
|
fmt.Printf("Target: %s\n", cred.Target())
|
|
|
|
fmt.Printf("Kind: %s\n", cred.Kind())
|
|
|
|
fmt.Printf("Creation: %s\n", cred.CreateTime().Format(time.RFC822))
|
|
|
|
|
|
|
|
switch cred := cred.(type) {
|
|
|
|
case *auth.Token:
|
|
|
|
fmt.Printf("Value: %s\n", cred.Value)
|
|
|
|
}
|
2019-11-10 17:50:56 +03:00
|
|
|
|
|
|
|
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
|
|
|
}
|