mirror of
https://git.sr.ht/~phw/scotty
synced 2025-06-01 19:38:34 +02:00
Allow editing config option after renaming
This commit is contained in:
parent
1ef498943b
commit
93767df567
3 changed files with 17 additions and 9 deletions
|
@ -38,10 +38,11 @@ func (b *SpotifyHistoryBackend) Name() string { return "spotify-history" }
|
||||||
|
|
||||||
func (b *SpotifyHistoryBackend) Options() []models.BackendOption {
|
func (b *SpotifyHistoryBackend) Options() []models.BackendOption {
|
||||||
return []models.BackendOption{{
|
return []models.BackendOption{{
|
||||||
Name: "archive-path",
|
Name: "archive-path",
|
||||||
Label: i18n.Tr("Archive path"),
|
Label: i18n.Tr("Archive path"),
|
||||||
Type: models.String,
|
Type: models.String,
|
||||||
Default: "./my_spotify_data_extended.zip",
|
Default: "./my_spotify_data_extended.zip",
|
||||||
|
MigrateFrom: "dir-path",
|
||||||
}, {
|
}, {
|
||||||
Name: "ignore-incognito",
|
Name: "ignore-incognito",
|
||||||
Label: i18n.Tr("Ignore listens in incognito mode"),
|
Label: i18n.Tr("Ignore listens in incognito mode"),
|
||||||
|
|
|
@ -83,6 +83,12 @@ func PromptExtraOptions(config config.ServiceConfig) (config.ServiceConfig, erro
|
||||||
current, exists := config.ConfigValues[opt.Name]
|
current, exists := config.ConfigValues[opt.Name]
|
||||||
if exists {
|
if exists {
|
||||||
opt.Default = fmt.Sprintf("%v", current)
|
opt.Default = fmt.Sprintf("%v", current)
|
||||||
|
} else if opt.MigrateFrom != "" {
|
||||||
|
// If there is an old value to migrate from, try that
|
||||||
|
fallback, exists := config.ConfigValues[opt.MigrateFrom]
|
||||||
|
if exists {
|
||||||
|
opt.Default = fmt.Sprintf("%v", fallback)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val, err := Prompt(opt)
|
val, err := Prompt(opt)
|
||||||
|
|
|
@ -25,9 +25,10 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type BackendOption struct {
|
type BackendOption struct {
|
||||||
Name string
|
Name string
|
||||||
Label string
|
Label string
|
||||||
Type OptionType
|
Type OptionType
|
||||||
Default string
|
Default string
|
||||||
Validate func(string) error
|
Validate func(string) error
|
||||||
|
MigrateFrom string
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue