Skip to content

Commit 1b1eeb9

Browse files
committed
Merge branch 'golangci' of github.com:gssbzn/promptui into gssbzn-golangci
2 parents 7064ee8 + bbfb055 commit 1b1eeb9

11 files changed

+58
-118
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
vendor
22
all-cover.txt
3+
bin/

.golangci.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
run:
2+
deadline: 5m
3+
4+
issues:
5+
# Disable maximums so we see all issues
6+
max-per-linter: 0
7+
max-same-issues: 0
8+
9+
# golangci-lint ignores missing docstrings by default. That's no good!
10+
exclude-use-default: false
11+
12+
linters:
13+
disable-all: true
14+
enable:
15+
- misspell
16+
- golint
17+
- goimports
18+
- ineffassign
19+
- deadcode
20+
- gofmt
21+
- govet
22+
- structcheck
23+
- unconvert
24+
- megacheck
25+
- typecheck
26+
- varcheck

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1111

1212
- Add support for configurable Stdin/Stdout on Prompt
1313
- Add support for setting initial cursor position
14+
- Switch to golangci-lint for linting
1415

1516
### Fixed
1617

1718
- Reduce tool-based deps, hopefully fixing any install issues
1819

19-
2020
## [0.6.0] - 2019-11-29
2121

2222
### Added

Makefile

+17-36
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,40 @@
1-
LINTERS=$(shell grep "// lint" tools/tools.go | awk '{gsub(/\"/, "", $$1); print $$1}' | awk -F / '{print $$NF}') \
2-
gofmt \
3-
vet
4-
5-
ci: $(LINTERS) cover
1+
export GO111MODULE := on
2+
export PATH := ./bin:$(PATH)
63

4+
ci: bootstrap lint cover
75
.PHONY: ci
86

97
#################################################
108
# Bootstrapping for base golang package and tool deps
119
#################################################
1210

13-
CMD_PKGS=$(shell grep ' "' tools/tools.go | awk -F '"' '{print $$2}')
14-
15-
define VENDOR_BIN_TMPL
16-
tools/vendor/bin/$(notdir $(1)): tools/vendor/$(1) | vendor tools/vendor
17-
GOBIN=`pwd`/tools/vendor/bin sh -c 'cd tools && go install ./vendor/$(1)'
18-
VENDOR_BINS += tools/vendor/bin/$(notdir $(1))
19-
tools/vendor/$(1): tools/vendor
20-
endef
21-
22-
$(foreach cmd_pkg,$(CMD_PKGS),$(eval $(call VENDOR_BIN_TMPL,$(cmd_pkg))))
23-
24-
$(patsubst %,%-bin,$(filter-out gofmt vet,$(LINTERS))): %-bin: tools/vendor/bin/%
25-
gofmt-bin vet-bin:
26-
27-
tools/vendor: tools/go.sum
28-
GO111MODULE=on sh -c 'cd tools && go mod vendor'
29-
30-
vendor: go.sum
31-
GO111MODULE=on go mod vendor
11+
bootstrap:
12+
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.21.0
13+
.PHONY: bootstrap
3214

3315
mod-update:
34-
GO111MODULE=on go get -u -m
35-
GO111MODULE=on go mod tidy
16+
go get -u -m
17+
go mod tidy
3618

3719
mod-tidy:
38-
GO111MODULE=on go mod tidy
20+
go mod tidy
3921

4022
.PHONY: $(CMD_PKGS)
4123
.PHONY: mod-update mod-tidy
4224

4325
#################################################
4426
# Test and linting
4527
#################################################
28+
# Run all the linters
29+
lint:
30+
bin/golangci-lint run ./...
31+
.PHONY: lint
4632

47-
test: vendor
33+
test:
4834
CGO_ENABLED=0 go test $$(go list ./... | grep -v generated)
35+
.PHONY: test
4936

50-
$(LINTERS): %: tools/vendor/bin/gometalinter %-bin tools/vendor
51-
PATH=`pwd`/tools/vendor/bin:$$PATH gometalinter --tests --disable-all --vendor \
52-
--deadline=5m -s data --enable $@ ./...
53-
54-
COVER_TEST_PKGS:=$(shell find . -type f -name '*_test.go' | grep -v vendor | rev | cut -d "/" -f 2- | rev | grep -v generated | sort -u)
37+
COVER_TEST_PKGS:=$(shell find . -type f -name '*_test.go' | rev | cut -d "/" -f 2- | rev | grep -v generated | sort -u)
5538
$(COVER_TEST_PKGS:=-cover): %-cover: all-cover.txt
5639
@CGO_ENABLED=0 go test -v [email protected] -covermode=atomic ./$*
5740
@if [ -f [email protected] ]; then \
@@ -62,7 +45,5 @@ $(COVER_TEST_PKGS:=-cover): %-cover: all-cover.txt
6245
all-cover.txt:
6346
echo "mode: atomic" > all-cover.txt
6447

65-
cover: vendor all-cover.txt $(COVER_TEST_PKGS:=-cover)
66-
67-
.PHONY: $(LINTERS) test
48+
cover: all-cover.txt $(COVER_TEST_PKGS:=-cover)
6849
.PHONY: cover all-cover.txt

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
Interactive prompt for command-line applications.
44

5-
We built Promptui because we wanted to make it easy and fun to explore cloud services with [manifold cli](https://github.com/manifoldco/manifold-cli).
5+
We built Promptui because we wanted to make it easy and fun to explore cloud
6+
services with [manifold cli](https://github.com/manifoldco/manifold-cli).
67

78
[Code of Conduct](./CODE_OF_CONDUCT.md) |
89
[Contribution Guidelines](./.github/CONTRIBUTING.md)

cursor.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func format(a []rune, c *Cursor) string {
100100

101101
out := make([]rune, 0)
102102
if i < len(a) {
103-
b = c.Cursor([]rune(a[i : i+1]))
103+
b = c.Cursor(a[i : i+1])
104104
out = append(out, a[:i]...) // does not include i
105105
out = append(out, b...) // add the cursor
106106
out = append(out, a[i+1:]...) // add the rest after i

screenbuf/screenbuf.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ type ScreenBuf struct {
2121
w io.Writer
2222
buf *bytes.Buffer
2323
reset bool
24-
flush bool
2524
cursor int
2625
height int
2726
}
@@ -77,11 +76,17 @@ func (s *ScreenBuf) Write(b []byte) (int, error) {
7776
if err != nil {
7877
return n, err
7978
}
80-
line := append(b, []byte("\n")...)
81-
n, err = s.buf.Write(line)
79+
80+
n, err = s.buf.Write(b)
8281
if err != nil {
8382
return n, err
8483
}
84+
85+
_, err = s.buf.Write([]byte("\n"))
86+
if err != nil {
87+
return n, err
88+
}
89+
8590
s.height++
8691
s.cursor++
8792
return n, nil

select.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ type Select struct {
7373
// For search mode to work, the Search property must be implemented.
7474
StartInSearchMode bool
7575

76-
label string
77-
7876
list *list.List
7977

8078
// A function that determines how to render the cursor
@@ -282,7 +280,7 @@ func (s *Select) innerRun(cursorPos, scroll int, top rune) (int, string, error)
282280

283281
cur.Backspace()
284282
if len(cur.Get()) > 0 {
285-
s.list.Search(string(cur.Get()))
283+
s.list.Search(cur.Get())
286284
} else {
287285
s.list.CancelSearch()
288286
}
@@ -293,7 +291,7 @@ func (s *Select) innerRun(cursorPos, scroll int, top rune) (int, string, error)
293291
default:
294292
if canSearch && searchMode {
295293
cur.Update(string(line))
296-
s.list.Search(string(cur.Get()))
294+
s.list.Search(cur.Get())
297295
}
298296
}
299297

tools/go.mod

-19
This file was deleted.

tools/go.sum

-42
This file was deleted.

tools/tools.go

-11
This file was deleted.

0 commit comments

Comments
 (0)