1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-31 14:24:25 +03:00

Remove return value of Alert/Confirm/Prompt

This might seem controversial; in many cases the client code gets longer,
because it needs an extra line for an explicit `return nil`. I still prefer
this, because it makes it clearer which calls can return errors.
This commit is contained in:
Stefan Haller
2024-09-05 11:10:27 +02:00
parent b15a1c7ae7
commit d4ef8e53d5
39 changed files with 303 additions and 131 deletions

View File

@ -118,13 +118,15 @@ func (self *StashController) handleStashApply(stashEntry *models.StashEntry) err
return apply()
}
return self.c.Confirm(types.ConfirmOpts{
self.c.Confirm(types.ConfirmOpts{
Title: self.c.Tr.StashApply,
Prompt: self.c.Tr.SureApplyStashEntry,
HandleConfirm: func() error {
return apply()
},
})
return nil
}
func (self *StashController) handleStashPop(stashEntry *models.StashEntry) error {
@ -142,17 +144,19 @@ func (self *StashController) handleStashPop(stashEntry *models.StashEntry) error
return pop()
}
return self.c.Confirm(types.ConfirmOpts{
self.c.Confirm(types.ConfirmOpts{
Title: self.c.Tr.StashPop,
Prompt: self.c.Tr.SurePopStashEntry,
HandleConfirm: func() error {
return pop()
},
})
return nil
}
func (self *StashController) handleStashDrop(stashEntry *models.StashEntry) error {
return self.c.Confirm(types.ConfirmOpts{
self.c.Confirm(types.ConfirmOpts{
Title: self.c.Tr.StashDrop,
Prompt: self.c.Tr.SureDropStashEntry,
HandleConfirm: func() error {
@ -165,6 +169,8 @@ func (self *StashController) handleStashDrop(stashEntry *models.StashEntry) erro
return nil
},
})
return nil
}
func (self *StashController) postStashRefresh() error {
@ -183,7 +189,7 @@ func (self *StashController) handleRenameStashEntry(stashEntry *models.StashEntr
},
)
return self.c.Prompt(types.PromptOpts{
self.c.Prompt(types.PromptOpts{
Title: message,
InitialContent: stashEntry.Name,
HandleConfirm: func(response string) error {
@ -198,4 +204,6 @@ func (self *StashController) handleRenameStashEntry(stashEntry *models.StashEntr
return nil
},
})
return nil
}