mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-15 00:15:32 +02:00
Extract a method CustomCommand.GetDescription
We'll reuse it in the next commit.
This commit is contained in:
@ -640,6 +640,14 @@ type CustomCommand struct {
|
|||||||
After *CustomCommandAfterHook `yaml:"after"`
|
After *CustomCommandAfterHook `yaml:"after"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *CustomCommand) GetDescription() string {
|
||||||
|
if c.Description != "" {
|
||||||
|
return c.Description
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.Command
|
||||||
|
}
|
||||||
|
|
||||||
type CustomCommandPrompt struct {
|
type CustomCommandPrompt struct {
|
||||||
// One of: 'input' | 'menu' | 'confirm' | 'menuFromCommand'
|
// One of: 'input' | 'menu' | 'confirm' | 'menuFromCommand'
|
||||||
Type string `yaml:"type"`
|
Type string `yaml:"type"`
|
||||||
|
@ -34,18 +34,13 @@ func (self *KeybindingCreator) call(customCommand config.CustomCommand, handler
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
description := customCommand.Description
|
|
||||||
if description == "" {
|
|
||||||
description = customCommand.Command
|
|
||||||
}
|
|
||||||
|
|
||||||
return lo.Map(viewNames, func(viewName string, _ int) *types.Binding {
|
return lo.Map(viewNames, func(viewName string, _ int) *types.Binding {
|
||||||
return &types.Binding{
|
return &types.Binding{
|
||||||
ViewName: viewName,
|
ViewName: viewName,
|
||||||
Key: keybindings.GetKey(customCommand.Key),
|
Key: keybindings.GetKey(customCommand.Key),
|
||||||
Modifier: gocui.ModNone,
|
Modifier: gocui.ModNone,
|
||||||
Handler: handler,
|
Handler: handler,
|
||||||
Description: description,
|
Description: customCommand.GetDescription(),
|
||||||
}
|
}
|
||||||
}), nil
|
}), nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user