mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
* WTF-657 Add spec coverage for cfg/common_settings.go Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-657 Add spec coverage for cfg/position_validation.go Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-657 Add spec coverage for cfg/validations.go Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-657 Add spec coverage for checklist/checklist.go Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-657 Add spec coverage for checklist/checklist_item.go Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-657 Add spec coverage for utils/conversions.go Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-657 Get rid of utils.Home() function Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-657 Add spec coverage for utils/homedir.go Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-657 Add spec coverage for utils/text.go Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-657 Clean up utils/utils.go Signed-off-by: Chris Cummer <chriscummer@me.com>
52 lines
1.3 KiB
Go
52 lines
1.3 KiB
Go
package cfg
|
|
|
|
import (
|
|
"github.com/olebedev/config"
|
|
)
|
|
|
|
const (
|
|
positionPath = "position"
|
|
)
|
|
|
|
// PositionSettings represents the onscreen location of a widget
|
|
type PositionSettings struct {
|
|
Validations *Validations
|
|
|
|
Height int
|
|
Left int
|
|
Top int
|
|
Width int
|
|
}
|
|
|
|
// NewPositionSettingsFromYAML creates and returns a new instance of cfg.Position
|
|
func NewPositionSettingsFromYAML(moduleName string, moduleConfig *config.Config) PositionSettings {
|
|
var currVal int
|
|
var err error
|
|
|
|
validations := NewValidations()
|
|
|
|
// Parse the positional data from the config data
|
|
currVal, err = moduleConfig.Int(positionPath + ".top")
|
|
validations.append("top", newPositionValidation("top", currVal, err))
|
|
|
|
currVal, err = moduleConfig.Int(positionPath + ".left")
|
|
validations.append("left", newPositionValidation("left", currVal, err))
|
|
|
|
currVal, err = moduleConfig.Int(positionPath + ".width")
|
|
validations.append("width", newPositionValidation("width", currVal, err))
|
|
|
|
currVal, err = moduleConfig.Int(positionPath + ".height")
|
|
validations.append("height", newPositionValidation("height", currVal, err))
|
|
|
|
pos := PositionSettings{
|
|
Validations: validations,
|
|
|
|
Top: validations.intValueFor("top"),
|
|
Left: validations.intValueFor("left"),
|
|
Width: validations.intValueFor("width"),
|
|
Height: validations.intValueFor("height"),
|
|
}
|
|
|
|
return pos
|
|
}
|