From c89ff1e58a227bf418c13b69e384c912aedd9744 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mickae=CC=88l=20Menu?= Date: Sat, 2 Jan 2021 12:08:58 +0100 Subject: [PATCH] Add the ./go shell script --- go | 6 ++++++ main.go | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100755 go diff --git a/go b/go new file mode 100755 index 0000000..25a7b09 --- /dev/null +++ b/go @@ -0,0 +1,6 @@ +#!/bin/sh + +VERSION=`git describe --tags 2> /dev/null` +BUILD=`git rev-parse --short HEAD` + +go $1 -tags "fts5 icu" -ldflags "-X=main.Version=$VERSION -X=main.Build=$BUILD" ${@:2} diff --git a/main.go b/main.go index b15bd7b..aee53ea 100644 --- a/main.go +++ b/main.go @@ -5,16 +5,25 @@ import ( "github.com/mickael-menu/zk/cmd" ) +var Version = "dev" +var Build = "dev" + var cli struct { - Init cmd.Init `cmd help:"Create a slip box in the given directory"` - New cmd.New `cmd help:"Add a new note to the slip box"` + Init cmd.Init `cmd help:"Create a slip box in the given directory"` + New cmd.New `cmd help:"Add a new note to the slip box"` + Version kong.VersionFlag `help:"Print zk version"` } func main() { // Create the dependency graph. container := cmd.NewContainer() - ctx := kong.Parse(&cli, kong.Name("zk")) + ctx := kong.Parse(&cli, + kong.Name("zk"), + kong.Vars{ + "version": Version, + }, + ) err := ctx.Run(container) ctx.FatalIfErrorf(err) }