summaryrefslogtreecommitdiffstatshomepage
path: root/commands/bridge_auth_rm.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/bridge_auth_rm.go')
-rw-r--r--commands/bridge_auth_rm.go38
1 files changed, 20 insertions, 18 deletions
diff --git a/commands/bridge_auth_rm.go b/commands/bridge_auth_rm.go
index 17e70625..b2a44e92 100644
--- a/commands/bridge_auth_rm.go
+++ b/commands/bridge_auth_rm.go
@@ -1,36 +1,38 @@
package commands
import (
- "fmt"
-
"github.com/spf13/cobra"
"github.com/MichaelMure/git-bug/bridge/core/auth"
)
-func runBridgeAuthRm(cmd *cobra.Command, args []string) error {
- cred, err := auth.LoadWithPrefix(repo, args[0])
+func newBridgeAuthRm() *cobra.Command {
+ env := newEnv()
+
+ cmd := &cobra.Command{
+ Use: "rm <id>",
+ Short: "Remove a credential.",
+ PreRunE: loadRepo(env),
+ RunE: func(cmd *cobra.Command, args []string) error {
+ return runBridgeAuthRm(env, args)
+ },
+ Args: cobra.ExactArgs(1),
+ }
+
+ return cmd
+}
+
+func runBridgeAuthRm(env *Env, args []string) error {
+ cred, err := auth.LoadWithPrefix(env.repo, args[0])
if err != nil {
return err
}
- err = auth.Remove(repo, cred.ID())
+ err = auth.Remove(env.repo, cred.ID())
if err != nil {
return err
}
- fmt.Printf("credential %s removed\n", cred.ID())
+ env.out.Printf("credential %s removed\n", cred.ID())
return nil
}
-
-var bridgeAuthRmCmd = &cobra.Command{
- Use: "rm <id>",
- Short: "Remove a credential.",
- PreRunE: loadRepo,
- RunE: runBridgeAuthRm,
- Args: cobra.ExactArgs(1),
-}
-
-func init() {
- bridgeAuthCmd.AddCommand(bridgeAuthRmCmd)
-}