2019-09-18 22:00:07 +03:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
2019-11-10 16:46:55 +03:00
|
|
|
"fmt"
|
|
|
|
|
2019-09-18 22:00:07 +03:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
|
|
|
"github.com/MichaelMure/git-bug/bridge/core"
|
|
|
|
)
|
|
|
|
|
2019-11-10 19:32:14 +03:00
|
|
|
func runBridgeAuthRm(cmd *cobra.Command, args []string) error {
|
2019-11-10 16:46:55 +03:00
|
|
|
token, err := core.LoadTokenPrefix(repo, args[0])
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = core.RemoveToken(repo, token.ID())
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Printf("token %s removed\n", token.ID())
|
|
|
|
return nil
|
2019-09-18 22:00:07 +03:00
|
|
|
}
|
|
|
|
|
2019-11-10 19:32:14 +03:00
|
|
|
var bridgeAuthRmCmd = &cobra.Command{
|
2019-11-10 17:50:56 +03:00
|
|
|
Use: "rm <id>",
|
2019-11-10 19:32:14 +03:00
|
|
|
Short: "Remove a credential.",
|
2019-09-18 22:00:07 +03:00
|
|
|
PreRunE: loadRepo,
|
2019-11-10 19:32:14 +03:00
|
|
|
RunE: runBridgeAuthRm,
|
2019-09-18 22:00:07 +03:00
|
|
|
Args: cobra.ExactArgs(1),
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
2019-11-10 19:32:14 +03:00
|
|
|
bridgeAuthCmd.AddCommand(bridgeAuthRmCmd)
|
2019-09-18 22:00:07 +03:00
|
|
|
}
|