diff options
author | Robin Jarry <robin@jarry.cc> | 2023-02-01 00:08:47 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-02-02 21:50:49 +0100 |
commit | b638f3fa8f5c3bc48d578d3109c2235e7023e07f (patch) | |
tree | 3500fe6a985820496d286e857e5749d7798bb159 /config | |
parent | c10cb370bb943fa6bb6a947e0a515674f1ee1958 (diff) | |
download | aerc-b638f3fa8f5c3bc48d578d3109c2235e7023e07f.tar.gz |
config: warn for all deprecated settings
index-format may be used in contextual [ui] sections. Display a warning
for every converted section so that users don't miss any.
Fixes: 535300cfdbfc ("config: add columns based index format")
Reported-by: Bence Ferdinandy <bence@ferdinandy.com>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
Diffstat (limited to 'config')
-rw-r--r-- | config/config.go | 8 | ||||
-rw-r--r-- | config/ui.go | 26 |
2 files changed, 28 insertions, 6 deletions
diff --git a/config/config.go b/config/config.go index 12da665b..2e45b0c8 100644 --- a/config/config.go +++ b/config/config.go @@ -183,3 +183,11 @@ func contains(list []string, v string) bool { } return false } + +// warning message related to configuration (deprecation, etc.) +type Warning struct { + Title string + Body string +} + +var Warnings []Warning diff --git a/config/ui.go b/config/ui.go index 752296a3..6c880293 100644 --- a/config/ui.go +++ b/config/ui.go @@ -321,24 +321,38 @@ func (config *UIConfig) parse(section *ini.Section) error { config.MessageViewThisDayTimeFormat = config.TimestampFormat } - if config.IndexFormat != "" { - log.Warnf("%s %s", - "The index-format setting has been replaced by index-columns.", - "index-format will be removed in aerc 0.17.") - } if key, err := section.GetKey("index-columns"); err == nil { columns, err := ParseColumnDefs(key, section) if err != nil { return err } config.IndexColumns = columns - config.IndexFormat = "" // to silence popup at startup } else if config.IndexFormat != "" { columns, err := convertIndexFormat(config.IndexFormat) if err != nil { return err } config.IndexColumns = columns + log.Warnf("%s %s", + "The index-format setting has been replaced by index-columns.", + "index-format will be removed in aerc 0.17.") + w := Warning{ + Title: "DEPRECATION WARNING: [" + section.Name() + "].index-format", + Body: fmt.Sprintf(` +The index-format setting is deprecated. It has been replaced by index-columns. + +Your configuration in this instance was automatically converted to: + +[%s] +%s +Your configuration file was not changed. To make this change permanent and to +dismiss this deprecation warning on launch, copy the above lines into aerc.conf +and remove index-format from it. See aerc-config(5) for more details. + +index-format will be removed in aerc 0.17. +`, section.Name(), ColumnDefsToIni(columns, "index-columns")), + } + Warnings = append(Warnings, w) } if key, err := section.GetKey("tab-title-account"); err == nil { val := key.Value() |