Move initialization code closer to the appropriate structs. (#17)
Reviewed-on: #17 Co-authored-by: Anna Rose Wiggins <annabunches@gmail.com> Co-committed-by: Anna Rose Wiggins <annabunches@gmail.com>
This commit is contained in:
parent
d9babf5dc0
commit
8d2b15a7c8
40 changed files with 1087 additions and 1109 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"errors"
|
||||
"slices"
|
||||
|
||||
"git.annabunches.net/annabunches/joyful/internal/configparser"
|
||||
"git.annabunches.net/annabunches/joyful/internal/logger"
|
||||
"github.com/holoplot/go-evdev"
|
||||
)
|
||||
|
@ -12,6 +13,14 @@ type RuleTargetModeSelect struct {
|
|||
Modes []string
|
||||
}
|
||||
|
||||
func NewRuleTargetModeSelectFromConfig(targetConfig configparser.RuleTargetConfigModeSelect, allModes []string) (*RuleTargetModeSelect, error) {
|
||||
if ok := validateModes(targetConfig.Modes, allModes); !ok {
|
||||
return nil, errors.New("undefined mode in mode select list")
|
||||
}
|
||||
|
||||
return NewRuleTargetModeSelect(targetConfig.Modes)
|
||||
}
|
||||
|
||||
func NewRuleTargetModeSelect(modes []string) (*RuleTargetModeSelect, error) {
|
||||
if len(modes) == 0 {
|
||||
return nil, errors.New("cannot create RuleTargetModeSelect: mode list is empty")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue