aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2024-06-27 00:24:12 +0200
committerRobin Jarry <robin@jarry.cc>2024-06-28 23:28:53 +0200
commit8e1f1dc199e1ea05cfd1319aa9338609e3ab3af6 (patch)
tree5adea2fc2ea9e770fc78ad3d2cc1da16ace7b163
parent7c5a1afbda60ec81e84161306c2cf71d974b341a (diff)
downloadaerc-8e1f1dc199e1ea05cfd1319aa9338609e3ab3af6.tar.gz
main: detect invalid arguments early
Currently, when running aerc --help or aerc --version, we get an obscure error when aerc is already running. $ aerc --help response: command not understood When it is not running, it starts but prints the same error message in the status line with weird colors. Avoid sending garbage into the control socket. Try to detect invalid arguments early. $ aerc --foobaz error: unknown argument: --foobaz Reported-by: Peter Sanchez <pjs@petersanchez.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
-rw-r--r--main.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/main.go b/main.go
index 21805345..40ce3cb8 100644
--- a/main.go
+++ b/main.go
@@ -161,6 +161,16 @@ func main() {
if err != nil {
die("%s", err)
}
+ switch {
+ case len(opts.Command) == 0:
+ break
+ case strings.HasPrefix(opts.Command[0], ":"):
+ case strings.HasPrefix(opts.Command[0], "mailto:"):
+ case strings.HasPrefix(opts.Command[0], "mbox:"):
+ break
+ default:
+ die("unknown argument: %s", opts.Command[0])
+ }
err = config.LoadConfigFromFile(
nil, opts.Accounts, opts.ConfAerc, opts.ConfBinds, opts.ConfAccounts,