aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-06-18 09:42:41 -0400
committerDrew DeVault <sir@cmpwn.com>2019-07-13 12:46:34 -0400
commit61a9e72f4c7276771d4ae966918358c27b90bc23 (patch)
treeb45c75f31c5b6ffecc91787c80d9faf17452cfce
parentb34242560e361d0fd73a9f49e4be7052b96cde5e (diff)
Add aerc -v to print the installed version0.1.3
-rw-r--r--Makefile4
-rw-r--r--aerc.go18
-rw-r--r--doc/aerc.1.scd7
3 files changed, 28 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 190fa4c..e511620 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,9 @@
.POSIX:
.SUFFIXES:
.SUFFIXES: .1 .5 .7 .1.scd .5.scd .7.scd
+
+VERSION?=0.1.1
+
VPATH=doc
PREFIX?=/usr/local
_INSTDIR=$(DESTDIR)$(PREFIX)
@@ -16,6 +19,7 @@ aerc: $(GOSRC)
go build $(GOFLAGS) \
-ldflags "-X main.Prefix=$(PREFIX)" \
-ldflags "-X main.ShareDir=$(SHAREDIR)" \
+ -ldflags "-X main.Version=$(VERSION)" \
-o $@
aerc.conf: config/aerc.conf.in
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
diff --git a/doc/aerc.1.scd b/doc/aerc.1.scd
index 4f0137c..4122269 100644
--- a/doc/aerc.1.scd
+++ b/doc/aerc.1.scd
@@ -6,10 +6,15 @@ aerc - the world's best email client
# SYNOPSIS
-_aerc_
+_aerc_ [-v]
For a guided tutorial, use *:help tutorial*.
+# OPTIONS
+
+*-v*
+ Prints the installed version of aerc and exits.
+
# RUNTIME COMMANDS
To execute a command, press ':' to bring up the command interface. Commands may