about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAsger Hautop Drewsen <asgerdrewsen@gmail.com>2019-07-16 12:09:25 +0200
committerDrew DeVault <sir@cmpwn.com>2019-07-17 15:59:41 -0400
commitd43684cd901b4a6d6e9c1439e762bd06d3b16f4a (patch)
tree5916b2a99d07d9cca23118f278603f0ef8ada59a
parent41390bc3e1e557eff15e8159767f206b3b74ea30 (diff)
downloadaerc-d43684cd901b4a6d6e9c1439e762bd06d3b16f4a.tar.gz
Show usage on getopt.Getopts error
-rw-r--r--aerc.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/aerc.go b/aerc.go
index dafdd22..40e6605 100644
--- a/aerc.go
+++ b/aerc.go
@@ -92,11 +92,16 @@ var (
 	Version  string
 )
 
+func usage() {
+	log.Fatal("Usage: aerc [-v]")
+}
+
 func main() {
 	// TODO: Support starting with mailto links, ad-hoc accounts, etc
 	opts, optind, err := getopt.Getopts(os.Args, "v")
 	if err != nil {
-		panic(err)
+		log.Print(err)
+		usage()
 	}
 	for _, opt := range opts {
 		switch opt.Option {
@@ -106,7 +111,7 @@ func main() {
 		}
 	}
 	if optind != len(os.Args) {
-		log.Fatal("Usage: aerc [-v]")
+		usage()
 	}
 
 	var (
> 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195