aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/accounts.go18
-rw-r--r--config/binds.go14
-rw-r--r--config/config.go23
3 files changed, 31 insertions, 24 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)
diff --git a/config/binds.go b/config/binds.go
index 8eda890d..bedc6d9a 100644
--- a/config/binds.go
+++ b/config/binds.go
@@ -101,12 +101,14 @@ func defaultBindsConfig() *BindingConfig {
var Binds = defaultBindsConfig()
-func parseBinds(root string) error {
- filename := path.Join(root, "binds.conf")
- if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
- fmt.Printf("%s not found, installing the system default\n", filename)
- if err := installTemplate(root, "binds.conf"); err != nil {
- return err
+func parseBinds(root string, filename string) error {
+ if filename == "" {
+ filename = path.Join(root, "binds.conf")
+ if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
+ fmt.Printf("%s not found, installing the system default\n", filename)
+ if err := installTemplate(root, "binds.conf"); err != nil {
+ return err
+ }
}
}
log.Debugf("Parsing key bindings configuration from %s", filename)
diff --git a/config/config.go b/config/config.go
index 092b73a6..1efbf896 100644
--- a/config/config.go
+++ b/config/config.go
@@ -77,18 +77,21 @@ func installTemplate(root, name string) error {
return nil
}
-func LoadConfigFromFile(root *string, accts []string) error {
+func LoadConfigFromFile(
+ root *string, accts []string, filename, bindPath, acctPath string,
+) error {
if root == nil {
_root := xdg.ConfigPath("aerc")
root = &_root
}
- filename := path.Join(*root, "aerc.conf")
-
- // if it doesn't exist copy over the template, then load
- if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
- fmt.Printf("%s not found, installing the system default\n", filename)
- if err := installTemplate(*root, "aerc.conf"); err != nil {
- return err
+ if filename == "" {
+ filename = path.Join(*root, "aerc.conf")
+ // if it doesn't exist copy over the template, then load
+ if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
+ fmt.Printf("%s not found, installing the system default\n", filename)
+ if err := installTemplate(*root, "aerc.conf"); err != nil {
+ return err
+ }
}
}
@@ -129,10 +132,10 @@ func LoadConfigFromFile(root *string, accts []string) error {
if err := parseTemplates(file); err != nil {
return err
}
- if err := parseAccounts(*root, accts); err != nil {
+ if err := parseAccounts(*root, accts, acctPath); err != nil {
return err
}
- if err := parseBinds(*root); err != nil {
+ if err := parseBinds(*root, bindPath); err != nil {
return err
}