mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-16 10:09:28 +02:00
Allow default values for boolean config settings
This commit is contained in:
parent
6ac2b4f142
commit
7666ca53a7
4 changed files with 10 additions and 12 deletions
|
@ -62,10 +62,7 @@ func (b *JSPFBackend) Options() []models.BackendOption {
|
||||||
|
|
||||||
func (b *JSPFBackend) FromConfig(config *config.ServiceConfig) models.Backend {
|
func (b *JSPFBackend) FromConfig(config *config.ServiceConfig) models.Backend {
|
||||||
b.filePath = config.GetString("file-path")
|
b.filePath = config.GetString("file-path")
|
||||||
b.append = true
|
b.append = config.GetBool("append", true)
|
||||||
if config.IsSet("append") {
|
|
||||||
b.append = config.GetBool("append")
|
|
||||||
}
|
|
||||||
b.playlist = jspf.Playlist{
|
b.playlist = jspf.Playlist{
|
||||||
Title: config.GetString("title"),
|
Title: config.GetString("title"),
|
||||||
Creator: config.GetString("username"),
|
Creator: config.GetString("username"),
|
||||||
|
|
|
@ -56,7 +56,7 @@ func (b *MalojaApiBackend) FromConfig(config *config.ServiceConfig) models.Backe
|
||||||
config.GetString("server-url"),
|
config.GetString("server-url"),
|
||||||
config.GetString("token"),
|
config.GetString("token"),
|
||||||
)
|
)
|
||||||
b.nofix = config.GetBool("nofix")
|
b.nofix = config.GetBool("nofix", false)
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,11 +56,8 @@ func (b *ScrobblerLogBackend) Options() []models.BackendOption {
|
||||||
|
|
||||||
func (b *ScrobblerLogBackend) FromConfig(config *config.ServiceConfig) models.Backend {
|
func (b *ScrobblerLogBackend) FromConfig(config *config.ServiceConfig) models.Backend {
|
||||||
b.filePath = config.GetString("file-path")
|
b.filePath = config.GetString("file-path")
|
||||||
b.includeSkipped = config.GetBool("include-skipped")
|
b.includeSkipped = config.GetBool("include-skipped", false)
|
||||||
b.append = true
|
b.append = config.GetBool("append", true)
|
||||||
if config.IsSet("append") {
|
|
||||||
b.append = config.GetBool("append")
|
|
||||||
}
|
|
||||||
b.log = ScrobblerLog{
|
b.log = ScrobblerLog{
|
||||||
Timezone: "UNKNOWN",
|
Timezone: "UNKNOWN",
|
||||||
Client: "Rockbox unknown $Revision$",
|
Client: "Rockbox unknown $Revision$",
|
||||||
|
|
|
@ -54,8 +54,12 @@ func (c *ServiceConfig) GetString(key string) string {
|
||||||
return cast.ToString(c.ConfigValues[key])
|
return cast.ToString(c.ConfigValues[key])
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ServiceConfig) GetBool(key string) bool {
|
func (c *ServiceConfig) GetBool(key string, defaultValue bool) bool {
|
||||||
return cast.ToBool(c.ConfigValues[key])
|
if c.IsSet(key) {
|
||||||
|
return cast.ToBool(c.ConfigValues[key])
|
||||||
|
} else {
|
||||||
|
return defaultValue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ServiceConfig) IsSet(key string) bool {
|
func (c *ServiceConfig) IsSet(key string) bool {
|
||||||
|
|
Loading…
Add table
Reference in a new issue