mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 04:15:48 +02:00
feat: add confirm prompt for custom keybindings
- Supports configuring a custom confirmation prompt via `config.yml` for custom keybindings. A new `CustomCommandPrompt.Body` field is used to store the immutable body text of the confirmation popup. - Adds a sample 'confirm' prompt to the example `config.yml`. - Updates the `Prompts` section of the documentation to include 'confirm' prompt type and also describe which fields pertain to it (i.e. `initialValue`). Closes: https://github.com/jesseduffield/lazygit/issues/1858 Signed-off-by: Michael Mead <mmead.developer@gmail.com>
This commit is contained in:
parent
582b1991a4
commit
9d304098bb
4 changed files with 38 additions and 10 deletions
|
@ -80,8 +80,12 @@ func (self *HandlerCreator) call(customCommand config.CustomCommand) func() erro
|
|||
f = func() error {
|
||||
return self.menuPromptFromCommand(resolvedPrompt, wrappedF)
|
||||
}
|
||||
case "confirm":
|
||||
f = func() error {
|
||||
return self.confirmPrompt(resolvedPrompt, g)
|
||||
}
|
||||
default:
|
||||
return self.c.ErrorMsg("custom command prompt must have a type of 'input', 'menu' or 'menuFromCommand'")
|
||||
return self.c.ErrorMsg("custom command prompt must have a type of 'input', 'menu', 'menuFromCommand', or 'confirm'")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,6 +116,14 @@ func (self *HandlerCreator) menuPrompt(prompt *config.CustomCommandPrompt, wrapp
|
|||
return self.c.Menu(types.CreateMenuOptions{Title: prompt.Title, Items: menuItems})
|
||||
}
|
||||
|
||||
func (self *HandlerCreator) confirmPrompt(prompt *config.CustomCommandPrompt, handleConfirm func() error) error {
|
||||
return self.c.Confirm(types.ConfirmOpts{
|
||||
Title: prompt.Title,
|
||||
Prompt: prompt.Body,
|
||||
HandleConfirm: handleConfirm,
|
||||
})
|
||||
}
|
||||
|
||||
func (self *HandlerCreator) menuPromptFromCommand(prompt *config.CustomCommandPrompt, wrappedF func(string) error) error {
|
||||
// Run and save output
|
||||
message, err := self.git.Custom.RunWithOutput(prompt.Command)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue