Merge pull request #71 from mcarmonaa/fix/cli-version

added version to cli
This commit is contained in:
Santiago M. Mola 2017-07-10 17:51:03 +02:00 committed by GitHub
commit c41038d444
3 changed files with 26 additions and 2 deletions

View File

@ -4,6 +4,11 @@ COVERAGE_MODE := atomic
LINGUIST_PATH = .linguist LINGUIST_PATH = .linguist
# build CLI
VERSION := $(shell git describe --tags --abbrev=0)
COMMIT := $(shell git rev-parse --short HEAD)
LDFLAGS = -s -X main.Version=$(VERSION) -X main.GitHash=$(COMMIT)
$(LINGUIST_PATH): $(LINGUIST_PATH):
git clone https://github.com/github/linguist.git $@ git clone https://github.com/github/linguist.git $@
@ -29,3 +34,6 @@ code-generate: $(LINGUIST_PATH)
clean: clean:
rm -rf $(LINGUIST_PATH) rm -rf $(LINGUIST_PATH)
build-cli:
go build -o enry -ldflags "$(LDFLAGS)" cli/enry/main.go

View File

@ -12,6 +12,11 @@ The recommended way to install simple-linguist
go get gopkg.in/src-d/enry.v1/... go get gopkg.in/src-d/enry.v1/...
``` ```
To build enry's CLI you must run
make build-cli
it generates a binary in the project's root directory called `enry`. You can move this binary to anywhere in your `PATH`.
Examples Examples
-------- --------

View File

@ -13,6 +13,11 @@ import (
"gopkg.in/src-d/enry.v1" "gopkg.in/src-d/enry.v1"
) )
var (
Version = "undefined"
GitHash = "undefined"
)
func main() { func main() {
flag.Usage = usage flag.Usage = usage
breakdownFlag := flag.Bool("breakdown", false, "") breakdownFlag := flag.Bool("breakdown", false, "")
@ -105,8 +110,14 @@ func main() {
func usage() { func usage() {
fmt.Fprintf( fmt.Fprintf(
os.Stderr, "enry, A simple (and faster) implementation of github/linguist \nusage: %s <path>\n %s [-json] [-breakdown] <path>\n %s [-json] [-breakdown]\n", os.Stderr,
os.Args[0], os.Args[0], os.Args[0], ` %[1]s %[2]s commit: %[3]s
enry, A simple (and faster) implementation of github/linguist
usage: %[1]s <path>
%[1]s [-json] [-breakdown] <path>
%[1]s [-json] [-breakdown]
`,
os.Args[0], Version, GitHash,
) )
} }