1package commands
2
3import (
4 "github.com/spf13/cobra"
5
6 "github.com/MichaelMure/git-bug/bridge/core/auth"
7)
8
9func newBridgeAuthRm() *cobra.Command {
10 env := newEnv()
11
12 cmd := &cobra.Command{
13 Use: "rm ID",
14 Short: "Remove a credential.",
15 PreRunE: loadRepo(env),
16 RunE: func(cmd *cobra.Command, args []string) error {
17 return runBridgeAuthRm(env, args)
18 },
19 Args: cobra.ExactArgs(1),
20 }
21
22 return cmd
23}
24
25func runBridgeAuthRm(env *Env, args []string) error {
26 cred, err := auth.LoadWithPrefix(env.repo, args[0])
27 if err != nil {
28 return err
29 }
30
31 err = auth.Remove(env.repo, cred.ID())
32 if err != nil {
33 return err
34 }
35
36 env.out.Printf("credential %s removed\n", cred.ID())
37 return nil
38}