diff --git a/pkg/config/user_config_validation.go b/pkg/config/user_config_validation.go index 0cbb0884e..ffb52d875 100644 --- a/pkg/config/user_config_validation.go +++ b/pkg/config/user_config_validation.go @@ -101,8 +101,8 @@ func validateCustomCommands(customCommands []CustomCommand) error { return err } - if len(customCommand.CommandMenu) > 0 && - (len(customCommand.Context) > 0 || + if len(customCommand.CommandMenu) > 0 { + if len(customCommand.Context) > 0 || len(customCommand.Command) > 0 || customCommand.Subprocess != nil || len(customCommand.Prompts) > 0 || @@ -110,12 +110,17 @@ func validateCustomCommands(customCommands []CustomCommand) error { customCommand.Stream != nil || customCommand.ShowOutput != nil || len(customCommand.OutputTitle) > 0 || - customCommand.After != nil) { - commandRef := "" - if len(customCommand.Key) > 0 { - commandRef = fmt.Sprintf(" with key '%s'", customCommand.Key) + customCommand.After != nil { + commandRef := "" + if len(customCommand.Key) > 0 { + commandRef = fmt.Sprintf(" with key '%s'", customCommand.Key) + } + return fmt.Errorf("Error with custom command%s: it is not allowed to use both commandMenu and any of the other fields except key and description.", commandRef) + } + + if err := validateCustomCommands(customCommand.CommandMenu); err != nil { + return err } - return fmt.Errorf("Error with custom command%s: it is not allowed to use both commandMenu and any of the other fields except key and description.", commandRef) } } return nil diff --git a/pkg/config/user_config_validation_test.go b/pkg/config/user_config_validation_test.go index d32b29c6f..87186a354 100644 --- a/pkg/config/user_config_validation_test.go +++ b/pkg/config/user_config_validation_test.go @@ -92,10 +92,7 @@ func TestUserConfigValidate_enums(t *testing.T) { {value: "", valid: true}, {value: "q", valid: true}, {value: "", valid: true}, - /* EXPECTED: {value: "invalid_value", valid: false}, - ACTUAL */ - {value: "invalid_value", valid: true}, }, }, {