git-bug/commands/bridge_auth_rm.go

37 lines
629 B
Go
Raw Normal View History

package commands
import (
"fmt"
"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 {
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-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.",
PreRunE: loadRepo,
2019-11-10 19:32:14 +03:00
RunE: runBridgeAuthRm,
Args: cobra.ExactArgs(1),
}
func init() {
2019-11-10 19:32:14 +03:00
bridgeAuthCmd.AddCommand(bridgeAuthRmCmd)
}