Skip to content

Commit

Permalink
add -version, and a Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
ellotheth committed Mar 19, 2016
1 parent e06830b commit b54b3ce
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ before_install:
- go get golang.org/x/tools/cmd/vet
- go get github.com/golang/lint/golint
- go get golang.org/x/tools/cmd/cover
- go get -v

script:
- go vet -x ./...
Expand Down
50 changes: 50 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
bin = pipethis
build = $(shell git describe --tags)-$(shell go env GOOS)-$(shell go env GOARCH)
goversion = $(word 3, $(shell go version))
dist = $(bin)-$(build).tar.bz2

all: test build

.PHONY: test
test: deps lint
@go get github.com/stretchr/testify/assert
@go test -cover -race ./...

.PHONY: build
build: deps
go build -o $(bin) -ldflags "-w -X main.bin=$(bin) -X main.build=$(build) -X main.builder=$(goversion)"

.PHONY: clean
clean: dist-clean
# go clean -r hits a bunch of the stdlib, so we go nuclear!
go clean -i
rm -rf $(GOPATH)/pkg/*
rm -f $(bin)*

.PHONY: dist
dist: build
tar -jcf $(dist) $(bin)
gpg --detach-sign --armor --output $(dist).sig $(dist)

.PHONY: dist-clean
dist-clean:
rm -f $(dist)*

.PHONY: lint
lint:
@go get github.com/golang/lint/golint
@go fmt ./...
@go vet ./...
@golint ./...

.PHONY: deps
deps:
@go get -v

.PHONY: watch
watch:
@while true; do \
make test; \
inotifywait -qqre modify,create,delete,move .; \
echo watching for changes...; \
done
12 changes: 12 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ import (
"github.com/ellotheth/pipethis/lookup"
)

var (
bin string
build string
builder string
)

// ReadSeekCloser combines io.ReadSeeker and io.Closer, because I'm super lazy
type ReadSeekCloser interface {
io.ReadSeeker
Expand All @@ -50,9 +56,15 @@ func main() {
noVerify = flag.Bool("no-verify", false, "Don't verify the author or signature")
sigSource = flag.String("signature", "", `Detached signature to verify. (default "<script location>.sig")`)
serviceName = flag.String("lookup-with", "keybase", "Key lookup service to use. Could be 'keybase' or 'local'.")
version = flag.Bool("version", false, "Print the pipethis version information and exit")
)
flag.Parse()

if *version {
log.Println(bin, build, "("+builder+")")
return
}

// download the script, store it someplace temporary
script, err := NewScript(flag.Arg(0))
if err != nil {
Expand Down

0 comments on commit b54b3ce

Please sign in to comment.