diff options
author | Steve Moyer <smoyer1@selesy.com> | 2023-01-17 20:18:56 -0500 |
---|---|---|
committer | Steve Moyer <smoyer1@selesy.com> | 2023-01-17 20:18:56 -0500 |
commit | 0bddfe1d9d737dfbd5c818ac32d79f578129d5d8 (patch) | |
tree | 3dc231d46b3e68620a2941d08300c9c45eea4468 /commands/root.go | |
parent | e689cc506775ec1daccaae9ec35c7a28b48b2f05 (diff) | |
download | git-bug-0bddfe1d9d737dfbd5c818ac32d79f578129d5d8.tar.gz |
fix(commands): create env.Env once for all Cobra commands
Resolves #996
Diffstat (limited to 'commands/root.go')
-rw-r--r-- | commands/root.go | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/commands/root.go b/commands/root.go index 0c854739..aace1956 100644 --- a/commands/root.go +++ b/commands/root.go @@ -7,10 +7,10 @@ import ( "github.com/spf13/cobra" - "github.com/MichaelMure/git-bug/commands/bridge" - "github.com/MichaelMure/git-bug/commands/bug" + bridgecmd "github.com/MichaelMure/git-bug/commands/bridge" + bugcmd "github.com/MichaelMure/git-bug/commands/bug" "github.com/MichaelMure/git-bug/commands/execenv" - "github.com/MichaelMure/git-bug/commands/user" + usercmd "github.com/MichaelMure/git-bug/commands/user" ) // These variables are initialized externally during the build. See the Makefile. @@ -68,20 +68,22 @@ the same git remote you are already using to collaborate with other people. child.GroupID = groupID } - addCmdWithGroup(bugcmd.NewBugCommand(), entityGroup) - addCmdWithGroup(usercmd.NewUserCommand(), entityGroup) - addCmdWithGroup(newLabelCommand(), entityGroup) + env := execenv.NewEnv() - addCmdWithGroup(newTermUICommand(), uiGroup) - addCmdWithGroup(newWebUICommand(), uiGroup) + addCmdWithGroup(bugcmd.NewBugCommand(env), entityGroup) + addCmdWithGroup(usercmd.NewUserCommand(env), entityGroup) + addCmdWithGroup(newLabelCommand(env), entityGroup) - addCmdWithGroup(newPullCommand(), remoteGroup) - addCmdWithGroup(newPushCommand(), remoteGroup) - addCmdWithGroup(bridgecmd.NewBridgeCommand(), remoteGroup) + addCmdWithGroup(newTermUICommand(env), uiGroup) + addCmdWithGroup(newWebUICommand(env), uiGroup) - cmd.AddCommand(newCommandsCommand()) - cmd.AddCommand(newVersionCommand()) - cmd.AddCommand(newWipeCommand()) + addCmdWithGroup(newPullCommand(env), remoteGroup) + addCmdWithGroup(newPushCommand(env), remoteGroup) + addCmdWithGroup(bridgecmd.NewBridgeCommand(env), remoteGroup) + + cmd.AddCommand(newCommandsCommand(env)) + cmd.AddCommand(newVersionCommand(env)) + cmd.AddCommand(newWipeCommand(env)) return cmd } |