mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 12:25:47 +02:00
Validate keys of custom commands
This commit is contained in:
parent
a5f78d3222
commit
5979b40546
2 changed files with 38 additions and 0 deletions
|
@ -22,6 +22,9 @@ func (config *UserConfig) Validate() error {
|
|||
if err := validateKeybindings(config.Keybinding); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := validateCustomCommands(config.CustomCommands); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -79,3 +82,20 @@ func validateKeybindings(keybindingConfig KeybindingConfig) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateCustomCommandKey(key string) error {
|
||||
if !isValidKeybindingKey(key) {
|
||||
return fmt.Errorf("Unrecognized key '%s' for custom command. For permitted values see %s",
|
||||
key, constants.Links.Docs.CustomKeybindings)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateCustomCommands(customCommands []CustomCommand) error {
|
||||
for _, customCommand := range customCommands {
|
||||
if err := validateCustomCommandKey(customCommand.Key); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue