@@ -8,11 +8,6 @@ import (
88 "github.com/jesseduffield/gocui"
99)
1010
11- type gitFlowOption struct {
12- handler func () error
13- description string
14- }
15-
1611func (gui * Gui ) gitFlowFinishBranch (gitFlowConfig string , branchName string ) error {
1712 // need to find out what kind of branch this is
1813 prefix := strings .SplitAfterN (branchName , "/" , 2 )[0 ]
@@ -41,11 +36,6 @@ func (gui *Gui) gitFlowFinishBranch(gitFlowConfig string, branchName string) err
4136 return gui .Errors .ErrSubProcess
4237}
4338
44- // GetDisplayStrings is a function.
45- func (r * gitFlowOption ) GetDisplayStrings (isFocused bool ) []string {
46- return []string {r .description }
47- }
48-
4939func (gui * Gui ) handleCreateGitFlowMenu (g * gocui.Gui , v * gocui.View ) error {
5040 branch := gui .getSelectedBranch ()
5141 if branch == nil {
@@ -70,37 +60,27 @@ func (gui *Gui) handleCreateGitFlowMenu(g *gocui.Gui, v *gocui.View) error {
7060 }
7161 }
7262
73- options := []* gitFlowOption {
63+ menuItems := []* menuItem {
7464 {
7565 // not localising here because it's one to one with the actual git flow commands
76- description : fmt .Sprintf ("finish branch '%s'" , branch .Name ),
77- handler : func () error {
66+ displayString : fmt .Sprintf ("finish branch '%s'" , branch .Name ),
67+ onPress : func () error {
7868 return gui .gitFlowFinishBranch (gitFlowConfig , branch .Name )
7969 },
8070 },
8171 {
82- description : "start feature" ,
83- handler : startHandler ("feature" ),
72+ displayString : "start feature" ,
73+ onPress : startHandler ("feature" ),
8474 },
8575 {
86- description : "start hotfix" ,
87- handler : startHandler ("hotfix" ),
76+ displayString : "start hotfix" ,
77+ onPress : startHandler ("hotfix" ),
8878 },
8979 {
90- description : "start release" ,
91- handler : startHandler ("release" ),
80+ displayString : "start release" ,
81+ onPress : startHandler ("release" ),
9282 },
93- {
94- description : gui .Tr .SLocalize ("cancel" ),
95- handler : func () error {
96- return nil
97- },
98- },
99- }
100-
101- handleMenuPress := func (index int ) error {
102- return options [index ].handler ()
10383 }
10484
105- return gui .createMenu ("git flow" , options , len ( options ), handleMenuPress )
85+ return gui .createMenuNew ("git flow" , menuItems , createMenuOptions {} )
10686}
0 commit comments