about summary refs log tree commit diff stats
path: root/aerc.go
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-06-18 09:42:41 -0400
committerDrew DeVault <sir@cmpwn.com>2019-06-18 09:50:06 -0400
commit74af57b6c617382ed0e8cd79626cac98ffc2e549 (patch)
tree213bb28bfd9ebafed60c91f3c0634ee72c6251a6 /aerc.go
parentce475e4952fe182a15d8897c3cd94f59df4b64e1 (diff)
downloadaerc-74af57b6c617382ed0e8cd79626cac98ffc2e549.tar.gz
Add aerc -v to print the installed version
Diffstat (limited to 'aerc.go')
-rw-r--r--aerc.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/aerc.go b/aerc.go
index ffce931..20e2bb1 100644
--- a/aerc.go
+++ b/aerc.go
@@ -8,6 +8,7 @@ import (
 	"os"
 	"time"
 
+	"git.sr.ht/~sircmpwn/getopt"
 	"github.com/mattn/go-isatty"
 
 	"git.sr.ht/~sircmpwn/aerc/commands"
@@ -53,9 +54,26 @@ func getCommands(selected libui.Drawable) []*commands.Commands {
 var (
 	Prefix   string
 	ShareDir string
+	Version  string
 )
 
 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)
+	}
+	for _, opt := range opts {
+		switch opt.Option {
+		case 'v':
+			fmt.Println("aerc " + Version)
+			return
+		}
+	}
+	if optind != len(os.Args) {
+		log.Fatal("Usage: aerc [-v]")
+	}
+
 	var (
 		logOut io.Writer
 		logger *log.Logger