aboutsummaryrefslogtreecommitdiffstats
path: root/commands/bridge
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2023-01-18 08:21:08 +0100
committerGitHub <noreply@github.com>2023-01-18 08:21:08 +0100
commit248486708911105e7067cb1061607b712c39a60e (patch)
tree414ad9f66ce05acdb169dcdb033c72ac2793f3c6 /commands/bridge
parent0290091317deb9e6c0ff99f9217065168620d2f0 (diff)
parent723b3c41470cafd240b0c2f174bc7e1762bc3680 (diff)
downloadgit-bug-248486708911105e7067cb1061607b712c39a60e.tar.gz
Merge pull request #998 from MichaelMure/fix/996/create-env-once
fix(commands): create env.Env once for all Cobra commands
Diffstat (limited to 'commands/bridge')
-rw-r--r--commands/bridge/bridge.go14
-rw-r--r--commands/bridge/bridge_auth.go10
-rw-r--r--commands/bridge/bridge_auth_addtoken.go3
-rw-r--r--commands/bridge/bridge_auth_rm.go4
-rw-r--r--commands/bridge/bridge_auth_show.go4
-rw-r--r--commands/bridge/bridge_new.go3
-rw-r--r--commands/bridge/bridge_pull.go3
-rw-r--r--commands/bridge/bridge_push.go4
-rw-r--r--commands/bridge/bridge_rm.go4
9 files changed, 17 insertions, 32 deletions
diff --git a/commands/bridge/bridge.go b/commands/bridge/bridge.go
index 980a38e2..9f7c5e50 100644
--- a/commands/bridge/bridge.go
+++ b/commands/bridge/bridge.go
@@ -7,9 +7,7 @@ import (
"github.com/MichaelMure/git-bug/commands/execenv"
)
-func NewBridgeCommand() *cobra.Command {
- env := execenv.NewEnv()
-
+func NewBridgeCommand(env *execenv.Env) *cobra.Command {
cmd := &cobra.Command{
Use: "bridge",
Short: "List bridges to other bug trackers",
@@ -20,11 +18,11 @@ func NewBridgeCommand() *cobra.Command {
Args: cobra.NoArgs,
}
- cmd.AddCommand(newBridgeAuthCommand())
- cmd.AddCommand(newBridgeNewCommand())
- cmd.AddCommand(newBridgePullCommand())
- cmd.AddCommand(newBridgePushCommand())
- cmd.AddCommand(newBridgeRm())
+ cmd.AddCommand(newBridgeAuthCommand(env))
+ cmd.AddCommand(newBridgeNewCommand(env))
+ cmd.AddCommand(newBridgePullCommand(env))
+ cmd.AddCommand(newBridgePushCommand(env))
+ cmd.AddCommand(newBridgeRm(env))
return cmd
}
diff --git a/commands/bridge/bridge_auth.go b/commands/bridge/bridge_auth.go
index 52e063e6..f27004e0 100644
--- a/commands/bridge/bridge_auth.go
+++ b/commands/bridge/bridge_auth.go
@@ -12,9 +12,7 @@ import (
"github.com/MichaelMure/git-bug/util/colors"
)
-func newBridgeAuthCommand() *cobra.Command {
- env := execenv.NewEnv()
-
+func newBridgeAuthCommand(env *execenv.Env) *cobra.Command {
cmd := &cobra.Command{
Use: "auth",
Short: "List all known bridge authentication credentials",
@@ -25,9 +23,9 @@ func newBridgeAuthCommand() *cobra.Command {
Args: cobra.NoArgs,
}
- cmd.AddCommand(newBridgeAuthAddTokenCommand())
- cmd.AddCommand(newBridgeAuthRm())
- cmd.AddCommand(newBridgeAuthShow())
+ cmd.AddCommand(newBridgeAuthAddTokenCommand(env))
+ cmd.AddCommand(newBridgeAuthRm(env))
+ cmd.AddCommand(newBridgeAuthShow(env))
return cmd
}
diff --git a/commands/bridge/bridge_auth_addtoken.go b/commands/bridge/bridge_auth_addtoken.go
index 2992fa63..5af27728 100644
--- a/commands/bridge/bridge_auth_addtoken.go
+++ b/commands/bridge/bridge_auth_addtoken.go
@@ -24,8 +24,7 @@ type bridgeAuthAddTokenOptions struct {
user string
}
-func newBridgeAuthAddTokenCommand() *cobra.Command {
- env := execenv.NewEnv()
+func newBridgeAuthAddTokenCommand(env *execenv.Env) *cobra.Command {
options := bridgeAuthAddTokenOptions{}
cmd := &cobra.Command{
diff --git a/commands/bridge/bridge_auth_rm.go b/commands/bridge/bridge_auth_rm.go
index d58ca63e..33253e26 100644
--- a/commands/bridge/bridge_auth_rm.go
+++ b/commands/bridge/bridge_auth_rm.go
@@ -8,9 +8,7 @@ import (
"github.com/MichaelMure/git-bug/commands/execenv"
)
-func newBridgeAuthRm() *cobra.Command {
- env := execenv.NewEnv()
-
+func newBridgeAuthRm(env *execenv.Env) *cobra.Command {
cmd := &cobra.Command{
Use: "rm BRIDGE_ID",
Short: "Remove a credential",
diff --git a/commands/bridge/bridge_auth_show.go b/commands/bridge/bridge_auth_show.go
index d373273d..25c517d3 100644
--- a/commands/bridge/bridge_auth_show.go
+++ b/commands/bridge/bridge_auth_show.go
@@ -13,9 +13,7 @@ import (
"github.com/MichaelMure/git-bug/commands/execenv"
)
-func newBridgeAuthShow() *cobra.Command {
- env := execenv.NewEnv()
-
+func newBridgeAuthShow(env *execenv.Env) *cobra.Command {
cmd := &cobra.Command{
Use: "show",
Short: "Display an authentication credential",
diff --git a/commands/bridge/bridge_new.go b/commands/bridge/bridge_new.go
index 2c51d9ef..07a555da 100644
--- a/commands/bridge/bridge_new.go
+++ b/commands/bridge/bridge_new.go
@@ -26,8 +26,7 @@ type bridgeNewOptions struct {
nonInteractive bool
}
-func newBridgeNewCommand() *cobra.Command {
- env := execenv.NewEnv()
+func newBridgeNewCommand(env *execenv.Env) *cobra.Command {
options := bridgeNewOptions{}
cmd := &cobra.Command{
diff --git a/commands/bridge/bridge_pull.go b/commands/bridge/bridge_pull.go
index d1fc279a..03f4929a 100644
--- a/commands/bridge/bridge_pull.go
+++ b/commands/bridge/bridge_pull.go
@@ -23,8 +23,7 @@ type bridgePullOptions struct {
noResume bool
}
-func newBridgePullCommand() *cobra.Command {
- env := execenv.NewEnv()
+func newBridgePullCommand(env *execenv.Env) *cobra.Command {
options := bridgePullOptions{}
cmd := &cobra.Command{
diff --git a/commands/bridge/bridge_push.go b/commands/bridge/bridge_push.go
index 51baed4d..08f9b872 100644
--- a/commands/bridge/bridge_push.go
+++ b/commands/bridge/bridge_push.go
@@ -15,9 +15,7 @@ import (
"github.com/MichaelMure/git-bug/util/interrupt"
)
-func newBridgePushCommand() *cobra.Command {
- env := execenv.NewEnv()
-
+func newBridgePushCommand(env *execenv.Env) *cobra.Command {
cmd := &cobra.Command{
Use: "push [NAME]",
Short: "Push updates to remote bug tracker",
diff --git a/commands/bridge/bridge_rm.go b/commands/bridge/bridge_rm.go
index 5d8d23c5..f6279ade 100644
--- a/commands/bridge/bridge_rm.go
+++ b/commands/bridge/bridge_rm.go
@@ -8,9 +8,7 @@ import (
"github.com/MichaelMure/git-bug/commands/execenv"
)
-func newBridgeRm() *cobra.Command {
- env := execenv.NewEnv()
-
+func newBridgeRm(env *execenv.Env) *cobra.Command {
cmd := &cobra.Command{
Use: "rm NAME",
Short: "Delete a configured bridge",