Add aerc -v to print the installed version

This commit is contained in:
Drew DeVault 2019-06-18 09:42:41 -04:00
parent ce475e4952
commit 74af57b6c6
3 changed files with 28 additions and 1 deletions

View file

@ -1,6 +1,9 @@
.POSIX: .POSIX:
.SUFFIXES: .SUFFIXES:
.SUFFIXES: .1 .5 .7 .1.scd .5.scd .7.scd .SUFFIXES: .1 .5 .7 .1.scd .5.scd .7.scd
VERSION?=0.1.1
VPATH=doc VPATH=doc
PREFIX?=/usr/local PREFIX?=/usr/local
_INSTDIR=$(DESTDIR)$(PREFIX) _INSTDIR=$(DESTDIR)$(PREFIX)
@ -16,6 +19,7 @@ aerc: $(GOSRC)
go build $(GOFLAGS) \ go build $(GOFLAGS) \
-ldflags "-X main.Prefix=$(PREFIX)" \ -ldflags "-X main.Prefix=$(PREFIX)" \
-ldflags "-X main.ShareDir=$(SHAREDIR)" \ -ldflags "-X main.ShareDir=$(SHAREDIR)" \
-ldflags "-X main.Version=$(VERSION)" \
-o $@ -o $@
aerc.conf: config/aerc.conf.in aerc.conf: config/aerc.conf.in

18
aerc.go
View file

@ -8,6 +8,7 @@ import (
"os" "os"
"time" "time"
"git.sr.ht/~sircmpwn/getopt"
"github.com/mattn/go-isatty" "github.com/mattn/go-isatty"
"git.sr.ht/~sircmpwn/aerc/commands" "git.sr.ht/~sircmpwn/aerc/commands"
@ -53,9 +54,26 @@ func getCommands(selected libui.Drawable) []*commands.Commands {
var ( var (
Prefix string Prefix string
ShareDir string ShareDir string
Version string
) )
func main() { 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 ( var (
logOut io.Writer logOut io.Writer
logger *log.Logger logger *log.Logger

View file

@ -6,11 +6,16 @@ aerc - the world's best email client
# SYNOPSIS # SYNOPSIS
_aerc_ _aerc_ [-v]
For a guided tutorial, use *:help tutorial* from aerc, or *man aerc-tutorial* For a guided tutorial, use *:help tutorial* from aerc, or *man aerc-tutorial*
from your terminal. from your terminal.
# OPTIONS
*-v*
Prints the installed version of aerc and exits.
# RUNTIME COMMANDS # RUNTIME COMMANDS
To execute a command, press ':' to bring up the command interface. Commands may To execute a command, press ':' to bring up the command interface. Commands may