Skip to content

Commit

Permalink
Improving CLI usage
Browse files Browse the repository at this point in the history
By default `make` only compiles binary for current OS.

This patch also improves error formatting of createConfig()
  • Loading branch information
Zachary Scott committed Jun 11, 2018
1 parent 3a1d7c4 commit 0e46b8d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
18 changes: 14 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,27 @@ SHA=$(shell git rev-parse --short HEAD)

GOFILES = $(shell find . -name '*.go' -not -path './vendor/*')

OS = $(shell uname)

CLIPATH=github.com/circleci/circleci-cli

EXECUTABLE=circleci-cli
BUILD_DIR=build

.PHONY: build/linux
.PHONY: build
build:
ifeq ($(OS), Darwin)
GOOS=darwin GOARCH=amd64 go build -o $(BUILD_DIR)/darwin/amd64/$(EXECUTABLE)
else ifeq ($(OS), Linux)
GOOS=linux GOARCH=amd64 go build -o $(BUILD_DIR)/linux/amd64/$(EXECUTABLE)
endif

.PHONY: build/*
$(BUILD_DIR)/%/amd64/$(EXECUTABLE): $(GOFILES)
GOOS=$* GOARCH=amd64 CGO_ENABLED=0 go build $(LDFLAGS) -o $(BUILD_DIR)/$*/amd64/$(EXECUTABLE) .

.PHONY: build
build: $(BUILD_DIR)/darwin/amd64/$(EXECUTABLE) $(BUILD_DIR)/linux/amd64/$(EXECUTABLE)
.PHONY: build-all
build-all: $(BUILD_DIR)/darwin/amd64/$(EXECUTABLE) $(BUILD_DIR)/linux/amd64/$(EXECUTABLE)

.PHONY: clean
clean:
Expand All @@ -27,7 +37,7 @@ test:

.PHONY: cover
cover:
go test -coverprofile=coverage.txt -covermode=count ./...
go test -race -coverprofile=coverage.txt ./...

.PHONY: lint
lint:
Expand Down
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func createConfig() (err error) {
Logger.FatalOnError("", err)
}
defer func() {
Logger.FatalOnError("Error closing config file", file.Close())
Logger.FatalOnError("Error closing config file", file.Close())
}()

// read flag values
Expand All @@ -139,7 +139,7 @@ func createConfig() (err error) {
Logger.FatalOnError("", err)
}

Logger.Info("Your configuration has been created in `%v`.\n", cfgPathDefault)
Logger.Infof("Your configuration has been created in `%v`.\n", cfgPathDefault)
Logger.Infoln("It can edited manually for advanced settings.")
return err
}

0 comments on commit 0e46b8d

Please sign in to comment.