Show usage on getopt.Getopts error
This commit is contained in:
parent
41390bc3e1
commit
d43684cd90
1 changed files with 7 additions and 2 deletions
9
aerc.go
9
aerc.go
|
@ -92,11 +92,16 @@ var (
|
||||||
Version string
|
Version string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func usage() {
|
||||||
|
log.Fatal("Usage: aerc [-v]")
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// TODO: Support starting with mailto links, ad-hoc accounts, etc
|
// TODO: Support starting with mailto links, ad-hoc accounts, etc
|
||||||
opts, optind, err := getopt.Getopts(os.Args, "v")
|
opts, optind, err := getopt.Getopts(os.Args, "v")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
log.Print(err)
|
||||||
|
usage()
|
||||||
}
|
}
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
switch opt.Option {
|
switch opt.Option {
|
||||||
|
@ -106,7 +111,7 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if optind != len(os.Args) {
|
if optind != len(os.Args) {
|
||||||
log.Fatal("Usage: aerc [-v]")
|
usage()
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
Loading…
Reference in a new issue