diff --git a/commands/bridge/bridge.go b/commands/bridge/bridge.go index 980a38e27647b6122f785c0ca56f5bda610e8b54..9f7c5e504234aeb003b2670075d4ac6d5b509574 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 52e063e67c5349c2721b52cb9f58c066b9e428d8..f27004e098f0eeba3e9fbe390c4e83bf1e9e61cd 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 2992fa63e5218a05c00f5f2d3fa875cd8b37a058..5af2772803e963d3586ed9d07afb348be14e5b8d 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 d58ca63e8603b082c869bfcbccd51a8bd1ab0e50..33253e26a2ce60d677eb7cd77059d34b7136e49c 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 d373273d6e4790b8ccc2defa856cd4369e5f0c38..25c517d33d16ea3ba815da29cb8154f9a706c49b 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 2c51d9ef8d982a449342a4b6222fe0ee317fa43e..07a555dafd8b3affcf4e16a784e56e40ae8ba2d3 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 d1fc279a89199c24e91907ec0b58c3160dff9e36..03f4929aad813c04bab96033916cafb2794eebf7 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 51baed4dfe8a6c13f922963b8d68122926388702..08f9b872a8dd8827296ead887b1183fe6493e34d 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 5d8d23c5f060ce68b2a80dab7f02ce5c8f9f8d77..f6279ade38e3087c91db52e9220689e483e98c78 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", diff --git a/commands/bug/bug.go b/commands/bug/bug.go index a5ce11ed7fb566be4ce56e1f464f9817fffedc94..7004f5c19eca7af76be683ceba37f6abbdd1d0f7 100644 --- a/commands/bug/bug.go +++ b/commands/bug/bug.go @@ -33,8 +33,7 @@ type bugOptions struct { outputFormat string } -func NewBugCommand() *cobra.Command { - env := execenv.NewEnv() +func NewBugCommand(env *execenv.Env) *cobra.Command { options := bugOptions{} cmd := &cobra.Command{ @@ -106,16 +105,16 @@ git bug status:open --by creation "foo bar" baz child.GroupID = groupID } - addCmdWithGroup(newBugDeselectCommand(), selectGroup) - addCmdWithGroup(newBugSelectCommand(), selectGroup) + addCmdWithGroup(newBugDeselectCommand(env), selectGroup) + addCmdWithGroup(newBugSelectCommand(env), selectGroup) - cmd.AddCommand(newBugCommentCommand()) - cmd.AddCommand(newBugLabelCommand()) - cmd.AddCommand(newBugNewCommand()) - cmd.AddCommand(newBugRmCommand()) - cmd.AddCommand(newBugShowCommand()) - cmd.AddCommand(newBugStatusCommand()) - cmd.AddCommand(newBugTitleCommand()) + cmd.AddCommand(newBugCommentCommand(env)) + cmd.AddCommand(newBugLabelCommand(env)) + cmd.AddCommand(newBugNewCommand(env)) + cmd.AddCommand(newBugRmCommand(env)) + cmd.AddCommand(newBugShowCommand(env)) + cmd.AddCommand(newBugStatusCommand(env)) + cmd.AddCommand(newBugTitleCommand(env)) return cmd } diff --git a/commands/bug/bug_comment.go b/commands/bug/bug_comment.go index 4dc8dc1f64a7edf5f19fafa6ebb6ab3c00fc2d1d..5cb8ff17a7435f9900c1b2c7217ceebc08f564b9 100644 --- a/commands/bug/bug_comment.go +++ b/commands/bug/bug_comment.go @@ -8,9 +8,7 @@ import ( "github.com/MichaelMure/git-bug/util/colors" ) -func newBugCommentCommand() *cobra.Command { - env := execenv.NewEnv() - +func newBugCommentCommand(env *execenv.Env) *cobra.Command { cmd := &cobra.Command{ Use: "comment [BUG_ID]", Short: "List a bug's comments", @@ -21,8 +19,8 @@ func newBugCommentCommand() *cobra.Command { ValidArgsFunction: BugCompletion(env), } - cmd.AddCommand(newBugCommentNewCommand()) - cmd.AddCommand(newBugCommentEditCommand()) + cmd.AddCommand(newBugCommentNewCommand(env)) + cmd.AddCommand(newBugCommentEditCommand(env)) return cmd } diff --git a/commands/bug/bug_comment_add.go b/commands/bug/bug_comment_add.go index ff406b4ff73ef405beb11c2f6c90b227383b355e..152a18930fe9553265aca43e96e41d9abd0b52bf 100644 --- a/commands/bug/bug_comment_add.go +++ b/commands/bug/bug_comment_add.go @@ -14,8 +14,7 @@ type bugCommentNewOptions struct { nonInteractive bool } -func newBugCommentNewCommand() *cobra.Command { - env := execenv.NewEnv() +func newBugCommentNewCommand(env *execenv.Env) *cobra.Command { options := bugCommentNewOptions{} cmd := &cobra.Command{ diff --git a/commands/bug/bug_comment_edit.go b/commands/bug/bug_comment_edit.go index ded3d82a8354e1af4668bbb5a82ea1a376e27421..e6f8d667c5271a0c254613b9e891677fbf98c716 100644 --- a/commands/bug/bug_comment_edit.go +++ b/commands/bug/bug_comment_edit.go @@ -13,8 +13,7 @@ type bugCommentEditOptions struct { nonInteractive bool } -func newBugCommentEditCommand() *cobra.Command { - env := execenv.NewEnv() +func newBugCommentEditCommand(env *execenv.Env) *cobra.Command { options := bugCommentEditOptions{} cmd := &cobra.Command{ diff --git a/commands/bug/bug_deselect.go b/commands/bug/bug_deselect.go index 090a7bf2d6e2567a95979a695981820fc5e8a565..5e9acc60ad68ae7cbbe9f64f2844cf577669512a 100644 --- a/commands/bug/bug_deselect.go +++ b/commands/bug/bug_deselect.go @@ -8,9 +8,7 @@ import ( "github.com/MichaelMure/git-bug/entities/bug" ) -func newBugDeselectCommand() *cobra.Command { - env := execenv.NewEnv() - +func newBugDeselectCommand(env *execenv.Env) *cobra.Command { cmd := &cobra.Command{ Use: "deselect", Short: "Clear the implicitly selected bug", diff --git a/commands/bug/bug_label.go b/commands/bug/bug_label.go index e6d0e6030ffcf771325b818690e002ffb9199f78..554496e35b7c96e567e3b739cfea6eab8b6ca7e6 100644 --- a/commands/bug/bug_label.go +++ b/commands/bug/bug_label.go @@ -6,9 +6,7 @@ import ( "github.com/MichaelMure/git-bug/commands/execenv" ) -func newBugLabelCommand() *cobra.Command { - env := execenv.NewEnv() - +func newBugLabelCommand(env *execenv.Env) *cobra.Command { cmd := &cobra.Command{ Use: "label [BUG_ID]", Short: "Display labels of a bug", @@ -19,8 +17,8 @@ func newBugLabelCommand() *cobra.Command { ValidArgsFunction: BugCompletion(env), } - cmd.AddCommand(newBugLabelNewCommand()) - cmd.AddCommand(newBugLabelRmCommand()) + cmd.AddCommand(newBugLabelNewCommand(env)) + cmd.AddCommand(newBugLabelRmCommand(env)) return cmd } diff --git a/commands/bug/bug_label_new.go b/commands/bug/bug_label_new.go index aa4f94638c2e57ffb7954191e5f5033c3a59c0db..1e1f2d4fb79bc788682e9e6fbe016fbda70596be 100644 --- a/commands/bug/bug_label_new.go +++ b/commands/bug/bug_label_new.go @@ -7,9 +7,7 @@ import ( "github.com/MichaelMure/git-bug/util/text" ) -func newBugLabelNewCommand() *cobra.Command { - env := execenv.NewEnv() - +func newBugLabelNewCommand(env *execenv.Env) *cobra.Command { cmd := &cobra.Command{ Use: "new [BUG_ID] LABEL...", Short: "Add a label to a bug", diff --git a/commands/bug/bug_label_rm.go b/commands/bug/bug_label_rm.go index 18510bbda3dbc5eccb341938a72a4c769945a9ae..6dda007c756706e2932646007519753e366186a2 100644 --- a/commands/bug/bug_label_rm.go +++ b/commands/bug/bug_label_rm.go @@ -7,9 +7,7 @@ import ( "github.com/MichaelMure/git-bug/util/text" ) -func newBugLabelRmCommand() *cobra.Command { - env := execenv.NewEnv() - +func newBugLabelRmCommand(env *execenv.Env) *cobra.Command { cmd := &cobra.Command{ Use: "rm [BUG_ID] LABEL...", Short: "Remove a label from a bug", diff --git a/commands/bug/bug_new.go b/commands/bug/bug_new.go index 9ef288e9c883f7561efdcd2f4c34dde6b6b290ad..e66967f9ff294d6767ce1dd9e07136970a9ced0a 100644 --- a/commands/bug/bug_new.go +++ b/commands/bug/bug_new.go @@ -15,8 +15,7 @@ type bugNewOptions struct { nonInteractive bool } -func newBugNewCommand() *cobra.Command { - env := execenv.NewEnv() +func newBugNewCommand(env *execenv.Env) *cobra.Command { options := bugNewOptions{} cmd := &cobra.Command{ diff --git a/commands/bug/bug_rm.go b/commands/bug/bug_rm.go index 386c57ec3cb11b5c1b74839965f6f6cf1bad514c..b9d3d525309b3ac93b54f97f90d635a77010306c 100644 --- a/commands/bug/bug_rm.go +++ b/commands/bug/bug_rm.go @@ -8,9 +8,7 @@ import ( "github.com/MichaelMure/git-bug/commands/execenv" ) -func newBugRmCommand() *cobra.Command { - env := execenv.NewEnv() - +func newBugRmCommand(env *execenv.Env) *cobra.Command { cmd := &cobra.Command{ Use: "rm BUG_ID", Short: "Remove an existing bug", diff --git a/commands/bug/bug_select.go b/commands/bug/bug_select.go index bfad899d32fff29eace8db141ed248815aef0471..652c61eae56169fdb93786416fe2f144e8e9a4dc 100644 --- a/commands/bug/bug_select.go +++ b/commands/bug/bug_select.go @@ -15,9 +15,7 @@ func ResolveSelected(repo *cache.RepoCache, args []string) (*cache.BugCache, []s return _select.Resolve[*cache.BugCache](repo, bug.Typename, bug.Namespace, repo.Bugs(), args) } -func newBugSelectCommand() *cobra.Command { - env := execenv.NewEnv() - +func newBugSelectCommand(env *execenv.Env) *cobra.Command { cmd := &cobra.Command{ Use: "select BUG_ID", Short: "Select a bug for implicit use in future commands", diff --git a/commands/bug/bug_show.go b/commands/bug/bug_show.go index 9f80120cf420fca53955516df085874ccfd06663..9a03c9a31ddb9c62c97bd6846be11fb85db7a50c 100644 --- a/commands/bug/bug_show.go +++ b/commands/bug/bug_show.go @@ -19,8 +19,7 @@ type bugShowOptions struct { format string } -func newBugShowCommand() *cobra.Command { - env := execenv.NewEnv() +func newBugShowCommand(env *execenv.Env) *cobra.Command { options := bugShowOptions{} cmd := &cobra.Command{ diff --git a/commands/bug/bug_status.go b/commands/bug/bug_status.go index 807a9a6035b5f46179c29d5c65a6e6d69027f1ff..59bef3fd02e222423ff742567e25ea20d06ec60d 100644 --- a/commands/bug/bug_status.go +++ b/commands/bug/bug_status.go @@ -6,9 +6,7 @@ import ( "github.com/MichaelMure/git-bug/commands/execenv" ) -func newBugStatusCommand() *cobra.Command { - env := execenv.NewEnv() - +func newBugStatusCommand(env *execenv.Env) *cobra.Command { cmd := &cobra.Command{ Use: "status [BUG_ID]", Short: "Display the status of a bug", @@ -19,8 +17,8 @@ func newBugStatusCommand() *cobra.Command { ValidArgsFunction: BugCompletion(env), } - cmd.AddCommand(newBugStatusCloseCommand()) - cmd.AddCommand(newBugStatusOpenCommand()) + cmd.AddCommand(newBugStatusCloseCommand(env)) + cmd.AddCommand(newBugStatusOpenCommand(env)) return cmd } diff --git a/commands/bug/bug_status_close.go b/commands/bug/bug_status_close.go index e52959b27cddc0f5a3f763d82429ef884bdc8cf9..1d06007b416608779e8a5be599c503ad1e22e7e4 100644 --- a/commands/bug/bug_status_close.go +++ b/commands/bug/bug_status_close.go @@ -6,9 +6,7 @@ import ( "github.com/MichaelMure/git-bug/commands/execenv" ) -func newBugStatusCloseCommand() *cobra.Command { - env := execenv.NewEnv() - +func newBugStatusCloseCommand(env *execenv.Env) *cobra.Command { cmd := &cobra.Command{ Use: "close [BUG_ID]", Short: "Mark a bug as closed", diff --git a/commands/bug/bug_status_open.go b/commands/bug/bug_status_open.go index 74177974a5f77fda5f776bf7a30b1094a6fbb84d..e99d2db03d166459627a84bb28b90b72cbbba6b4 100644 --- a/commands/bug/bug_status_open.go +++ b/commands/bug/bug_status_open.go @@ -6,9 +6,7 @@ import ( "github.com/MichaelMure/git-bug/commands/execenv" ) -func newBugStatusOpenCommand() *cobra.Command { - env := execenv.NewEnv() - +func newBugStatusOpenCommand(env *execenv.Env) *cobra.Command { cmd := &cobra.Command{ Use: "open [BUG_ID]", Short: "Mark a bug as open", diff --git a/commands/bug/bug_title.go b/commands/bug/bug_title.go index e59a1fdc028d029fb0041808506277981219ffe5..47603410427e20c2fc433588227a52b60076361f 100644 --- a/commands/bug/bug_title.go +++ b/commands/bug/bug_title.go @@ -6,9 +6,7 @@ import ( "github.com/MichaelMure/git-bug/commands/execenv" ) -func newBugTitleCommand() *cobra.Command { - env := execenv.NewEnv() - +func newBugTitleCommand(env *execenv.Env) *cobra.Command { cmd := &cobra.Command{ Use: "title [BUG_ID]", Short: "Display the title of a bug", @@ -19,7 +17,7 @@ func newBugTitleCommand() *cobra.Command { ValidArgsFunction: BugCompletion(env), } - cmd.AddCommand(newBugTitleEditCommand()) + cmd.AddCommand(newBugTitleEditCommand(env)) return cmd } diff --git a/commands/bug/bug_title_edit.go b/commands/bug/bug_title_edit.go index 59898530c2dd1fdf000815074ff6a1978fdaaed8..fc60824f557afa6847eea8a462d3e0d25f76e5dc 100644 --- a/commands/bug/bug_title_edit.go +++ b/commands/bug/bug_title_edit.go @@ -13,8 +13,7 @@ type bugTitleEditOptions struct { nonInteractive bool } -func newBugTitleEditCommand() *cobra.Command { - env := execenv.NewEnv() +func newBugTitleEditCommand(env *execenv.Env) *cobra.Command { options := bugTitleEditOptions{} cmd := &cobra.Command{ diff --git a/commands/commands.go b/commands/commands.go index 7d2fc37d7feef4edc198734198a74d6238e982e5..173a0904485ec60e842bd9fceebd81c439214ac7 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -12,8 +12,7 @@ type commandOptions struct { desc bool } -func newCommandsCommand() *cobra.Command { - env := execenv.NewEnv() +func newCommandsCommand(env *execenv.Env) *cobra.Command { options := commandOptions{} cmd := &cobra.Command{ diff --git a/commands/label.go b/commands/label.go index 08b9e31fc450c278956cab38daf60b387b1b9f3e..d59479b417e560ae00142c0196410a0103f133e8 100644 --- a/commands/label.go +++ b/commands/label.go @@ -6,9 +6,7 @@ import ( "github.com/MichaelMure/git-bug/commands/execenv" ) -func newLabelCommand() *cobra.Command { - env := execenv.NewEnv() - +func newLabelCommand(env *execenv.Env) *cobra.Command { cmd := &cobra.Command{ Use: "label", Short: "List valid labels", diff --git a/commands/pull.go b/commands/pull.go index 2e2639e1571107c2f2fb6145e8e5e5c0d8a22f93..91eadcf8f02e13df2fb1bf13f798e414bb82f187 100644 --- a/commands/pull.go +++ b/commands/pull.go @@ -10,9 +10,7 @@ import ( "github.com/MichaelMure/git-bug/entity" ) -func newPullCommand() *cobra.Command { - env := execenv.NewEnv() - +func newPullCommand(env *execenv.Env) *cobra.Command { cmd := &cobra.Command{ Use: "pull [REMOTE]", Short: "Pull updates from a git remote", diff --git a/commands/push.go b/commands/push.go index d45e301a26af79c33f629f2ae2be7ff444ccf508..254bbb27a382f233feba50cc293db56dac3d1f66 100644 --- a/commands/push.go +++ b/commands/push.go @@ -9,9 +9,7 @@ import ( "github.com/MichaelMure/git-bug/commands/execenv" ) -func newPushCommand() *cobra.Command { - env := execenv.NewEnv() - +func newPushCommand(env *execenv.Env) *cobra.Command { cmd := &cobra.Command{ Use: "push [REMOTE]", Short: "Push updates to a git remote", diff --git a/commands/root.go b/commands/root.go index 0c8547396d005abe04e4b78104e0793a9c9ac399..aace19560038c2849afebf1f737efa429d4f4ffe 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 } diff --git a/commands/termui.go b/commands/termui.go index 1cfdd8f396cb005ad9e67372104b630c816da4b6..08eba1d699616417ea2a48c70e6259b2be53ad8f 100644 --- a/commands/termui.go +++ b/commands/termui.go @@ -7,9 +7,7 @@ import ( "github.com/MichaelMure/git-bug/termui" ) -func newTermUICommand() *cobra.Command { - env := execenv.NewEnv() - +func newTermUICommand(env *execenv.Env) *cobra.Command { cmd := &cobra.Command{ Use: "termui", Aliases: []string{"tui"}, diff --git a/commands/user/user.go b/commands/user/user.go index a9a45726affa815efd9ca45a47bc4be5366ecd6b..de5c1ccdadcefa1a8366c958836e81d6a31e23d2 100644 --- a/commands/user/user.go +++ b/commands/user/user.go @@ -16,8 +16,7 @@ type userOptions struct { format string } -func NewUserCommand() *cobra.Command { - env := execenv.NewEnv() +func NewUserCommand(env *execenv.Env) *cobra.Command { options := userOptions{} cmd := &cobra.Command{ @@ -29,9 +28,9 @@ func NewUserCommand() *cobra.Command { }), } - cmd.AddCommand(newUserNewCommand()) - cmd.AddCommand(newUserShowCommand()) - cmd.AddCommand(newUserAdoptCommand()) + cmd.AddCommand(newUserNewCommand(env)) + cmd.AddCommand(newUserShowCommand(env)) + cmd.AddCommand(newUserAdoptCommand(env)) flags := cmd.Flags() flags.SortFlags = false diff --git a/commands/user/user_adopt.go b/commands/user/user_adopt.go index 30fdb442392a43f3cde80a22918067ca162d9837..47f0f04eaea6cd277021072f38014dade3c3ebea 100644 --- a/commands/user/user_adopt.go +++ b/commands/user/user_adopt.go @@ -7,9 +7,7 @@ import ( "github.com/MichaelMure/git-bug/commands/execenv" ) -func newUserAdoptCommand() *cobra.Command { - env := execenv.NewEnv() - +func newUserAdoptCommand(env *execenv.Env) *cobra.Command { cmd := &cobra.Command{ Use: "adopt USER_ID", Short: "Adopt an existing identity as your own", diff --git a/commands/user/user_new.go b/commands/user/user_new.go index 7b287492d15b6ea451b01b1de5c5adc6ea5b5837..ba4198f8a4322426590985906ef77afb377cda3f 100644 --- a/commands/user/user_new.go +++ b/commands/user/user_new.go @@ -14,9 +14,7 @@ type userNewOptions struct { nonInteractive bool } -func newUserNewCommand() *cobra.Command { - env := execenv.NewEnv() - +func newUserNewCommand(env *execenv.Env) *cobra.Command { options := userNewOptions{} cmd := &cobra.Command{ Use: "new", diff --git a/commands/user/user_show.go b/commands/user/user_show.go index 225d0ef44be3a4fca1920242ecc10aa71bbc2f9b..049eee93c4e4d460277f6ac05c1e228a052a8ec7 100644 --- a/commands/user/user_show.go +++ b/commands/user/user_show.go @@ -16,8 +16,7 @@ type userShowOptions struct { fields string } -func newUserShowCommand() *cobra.Command { - env := execenv.NewEnv() +func newUserShowCommand(env *execenv.Env) *cobra.Command { options := userShowOptions{} cmd := &cobra.Command{ diff --git a/commands/version.go b/commands/version.go index 0e54bb92b244f708dc9f4d3476d65a164d2bb54d..957cc65382bfca3d55524780e5f22f20d5da0ea2 100644 --- a/commands/version.go +++ b/commands/version.go @@ -14,8 +14,7 @@ type versionOptions struct { all bool } -func newVersionCommand() *cobra.Command { - env := execenv.NewEnv() +func newVersionCommand(env *execenv.Env) *cobra.Command { options := versionOptions{} cmd := &cobra.Command{ diff --git a/commands/webui.go b/commands/webui.go index 31313146978c6298fb6fb11bd74b965b36a83412..3129a222abce5836b894a7c887c4287dde3fe0f6 100644 --- a/commands/webui.go +++ b/commands/webui.go @@ -42,8 +42,7 @@ type webUIOptions struct { query string } -func newWebUICommand() *cobra.Command { - env := execenv.NewEnv() +func newWebUICommand(env *execenv.Env) *cobra.Command { options := webUIOptions{} cmd := &cobra.Command{ diff --git a/commands/wipe.go b/commands/wipe.go index 0ec53f49525412ba726716b4d20c31778d606f01..ce9da032ec4d050e1d9c6ad7a18249db03609dc7 100644 --- a/commands/wipe.go +++ b/commands/wipe.go @@ -6,9 +6,7 @@ import ( "github.com/MichaelMure/git-bug/commands/execenv" ) -func newWipeCommand() *cobra.Command { - env := execenv.NewEnv() - +func newWipeCommand(env *execenv.Env) *cobra.Command { cmd := &cobra.Command{ Use: "wipe", Short: "Wipe git-bug from the git repository",