aboutsummaryrefslogtreecommitdiffstats
path: root/config/accounts.go
diff options
context:
space:
mode:
authorBence Ferdinandy <bence@ferdinandy.com>2024-01-20 21:29:23 +0100
committerRobin Jarry <robin@jarry.cc>2024-01-21 10:45:53 +0100
commitc8017f67531c493451c6f25335990a74a1f81699 (patch)
treeb8962baaae8caafcc2874f09a4bcb8bec2411e5d /config/accounts.go
parent5b76547c3b3566ef878d0937b5cb1e91376d2206 (diff)
downloadaerc-c8017f67531c493451c6f25335990a74a1f81699.tar.gz
main: add flags to override config files
Add --aerc-conf, --binds-conf and --accounts-conf CLI flags, which respectively override the default aerc.conf, binds.conf and accounts.conf configuration files. If the specified files do not exist or cannot be read, exit with an error. Implements: https://todo.sr.ht/~rjarry/aerc/209 Changelog-added: CLI flags to override paths to config files. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'config/accounts.go')
-rw-r--r--config/accounts.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/config/accounts.go b/config/accounts.go
index dbc0cdb4..413b77b1 100644
--- a/config/accounts.go
+++ b/config/accounts.go
@@ -119,14 +119,16 @@ const (
var Accounts []*AccountConfig
-func parseAccounts(root string, accts []string) error {
- filename := path.Join(root, "accounts.conf")
- err := checkConfigPerms(filename)
- if errors.Is(err, os.ErrNotExist) {
- // No config triggers account configuration wizard
- return nil
- } else if err != nil {
- return err
+func parseAccounts(root string, accts []string, filename string) error {
+ if filename == "" {
+ filename = path.Join(root, "accounts.conf")
+ err := checkConfigPerms(filename)
+ if errors.Is(err, os.ErrNotExist) {
+ // No config triggers account configuration wizard
+ return nil
+ } else if err != nil {
+ return err
+ }
}
log.Debugf("Parsing accounts configuration from %s", filename)