aboutsummaryrefslogtreecommitdiffstats
path: root/main.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 /main.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 'main.go')
-rw-r--r--main.go18
1 files changed, 13 insertions, 5 deletions
diff --git a/main.go b/main.go
index ad926a63..06178d2d 100644
--- a/main.go
+++ b/main.go
@@ -119,10 +119,13 @@ func setWindowTitle() {
}
type Opts struct {
- Help bool `opt:"-h" action:"ShowHelp"`
- Version bool `opt:"-v" action:"ShowVersion"`
- Accounts []string `opt:"-a" action:"ParseAccounts" metavar:"<account>"`
- Command []string `opt:"..." required:"false" metavar:"mailto:<address> | mbox:<file> | :<command...>"`
+ Help bool `opt:"-h" action:"ShowHelp"`
+ Version bool `opt:"-v" action:"ShowVersion"`
+ Accounts []string `opt:"-a" action:"ParseAccounts" metavar:"<account>"`
+ ConfAerc string `opt:"--aerc-conf"`
+ ConfAccounts string `opt:"--accounts-conf"`
+ ConfBinds string `opt:"--binds-conf"`
+ Command []string `opt:"..." required:"false" metavar:"mailto:<address> | mbox:<file> | :<command...>"`
}
func (o *Opts) ShowHelp(arg string) error {
@@ -138,6 +141,9 @@ Options:
accounts. It can also be a comma separated list of names.
This option may be specified multiple times. The account
order will be preserved.
+ --aerc-conf Path to configuration file to be used instead of the default.
+ --accounts-conf Path to configuration file to be used instead of the default.
+ --binds-conf Path to configuration file to be used instead of the default.
mailto:<address> Open the composer with the address(es) in the To field.
If aerc is already running, the composer is started in
this instance, otherwise aerc will be started.
@@ -186,7 +192,9 @@ func main() {
retryExec = true
}
- err = config.LoadConfigFromFile(nil, opts.Accounts)
+ err = config.LoadConfigFromFile(
+ nil, opts.Accounts, opts.ConfAerc, opts.ConfBinds, opts.ConfAccounts,
+ )
if err != nil {
die("failed to load config: %s", err)
}