Extract a method CustomCommand.GetDescription

We'll reuse it in the next commit.
This commit is contained in:
Stefan Haller 2025-02-15 16:19:19 +01:00
parent f93948cb23
commit e799976b8a
2 changed files with 9 additions and 6 deletions

View file

@ -640,6 +640,14 @@ type CustomCommand struct {
After *CustomCommandAfterHook `yaml:"after"`
}
func (c *CustomCommand) GetDescription() string {
if c.Description != "" {
return c.Description
}
return c.Command
}
type CustomCommandPrompt struct {
// One of: 'input' | 'menu' | 'confirm' | 'menuFromCommand'
Type string `yaml:"type"`

View file

@ -34,18 +34,13 @@ func (self *KeybindingCreator) call(customCommand config.CustomCommand, handler
return nil, err
}
description := customCommand.Description
if description == "" {
description = customCommand.Command
}
return lo.Map(viewNames, func(viewName string, _ int) *types.Binding {
return &types.Binding{
ViewName: viewName,
Key: keybindings.GetKey(customCommand.Key),
Modifier: gocui.ModNone,
Handler: handler,
Description: description,
Description: customCommand.GetDescription(),
}
}), nil
}