Skip to content

Commit

Permalink
version: Add a version command
Browse files Browse the repository at this point in the history
Fixes: #32
  • Loading branch information
dlespiau committed Dec 13, 2018
1 parent 9ac2e63 commit 1d3f2c0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

all: jk

VERSION := $(shell git describe)

jk: pkg/__std/lib/assets_vfsdata.go
GO111MODULE=on go build -o $@
GO111MODULE=on go build -o $@ -ldflags "-X main.Version=$(VERSION)"

pkg/__std/lib/assets_vfsdata.go: std/build/std.js
GO111MODULE=on go generate ./pkg/__std/lib
Expand Down
24 changes: 24 additions & 0 deletions version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package main

import (
"fmt"

"github.com/spf13/cobra"
)

var versionCmd = &cobra.Command{
Use: "version",
Short: "Print jk's version",
Run: version,
}

func init() {
jk.AddCommand(versionCmd)
}

// Version is jk's version. It's populated a link time.
var Version = "git"

func version(cmd *cobra.Command, args []string) {
fmt.Println("version:", Version)
}

0 comments on commit 1d3f2c0

Please sign in to comment.