Skip to content

Commit 7c28529

Browse files
authored
Move to go.nhat.io (#22)
1 parent 047d5fe commit 7c28529

27 files changed

+270
-216
lines changed

.github/workflows/lint.yaml

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,32 @@
11
name: lint
2+
23
on:
34
push:
4-
tags:
5-
- v*
65
branches:
76
- master
8-
- main
97
pull_request:
8+
109
jobs:
1110
lint:
1211
name: lint
1312
runs-on: ubuntu-latest
1413
steps:
1514
- uses: actions/checkout@v3
16-
- name: golangci-lint
15+
16+
- name: Install Go
17+
uses: actions/setup-go@v3
18+
with:
19+
go-version: ${{ env.GO_VERSION }}
20+
21+
- id: get-lint-version
22+
run: |
23+
make golangci-lint-version
24+
25+
- name: lint
1726
uses: golangci/golangci-lint-action@v3
1827
with:
1928
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
20-
version: v1.46.2
29+
version: ${{ steps.get-lint-version.outputs.GOLANGCI_LINT_VERSION }}
2130

2231
# Optional: working directory, useful for monorepos
2332
# working-directory: somedir

.github/workflows/test.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ on:
88

99
env:
1010
GO111MODULE: "on"
11-
GO_LATEST_VERSION: "1.18.x"
11+
GO_LATEST_VERSION: "1.19.x"
1212

1313
jobs:
1414
test:
1515
strategy:
1616
fail-fast: false
1717
matrix:
1818
os: [ ubuntu-latest, macos-latest ]
19-
go-version: [ 1.17.x, 1.18.x ]
19+
go-version: [ 1.17.x, 1.18.x, 1.19.x ]
2020
runs-on: ${{ matrix.os }}
2121
steps:
2222
- name: Install Go
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: 'update-registry'
3+
4+
on:
5+
push:
6+
tags:
7+
- v*
8+
workflow_dispatch:
9+
10+
env:
11+
MODULE_NAME: surveyexpect
12+
13+
jobs:
14+
notify:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
registry: [ go.nhat.io, go-staging.nhat.io ]
19+
steps:
20+
- name: notify ${{ matrix.registry }}
21+
uses: benc-uk/workflow-dispatch@v1
22+
with:
23+
workflow: build
24+
repo: nhatthm/${{ matrix.registry }}
25+
token: ${{ secrets.REGISTRY_TOKEN }}
26+
inputs: '{"modules": "${{ env.MODULE_NAME }}"}'
27+
ref: 'master'

.golangci.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@ linters:
3030
- gomnd
3131
- ifshort
3232
- interfacer
33+
- ireturn
3334
- lll
3435
- maligned
35-
- nonamedreturns
36+
- nolintlint # https://github.com/golangci/golangci-lint/issues/3063
3637
- paralleltest
3738
- scopelint
39+
- tagliatelle
3840
- testpackage
39-
- wrapcheck
4041
- varnamelen
42+
- wrapcheck
4143

4244
issues:
4345
exclude-use-default: false

Makefile

+21-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,33 @@
1-
VENDORDIR = vendor
1+
VENDOR_DIR = vendor
22

3-
GO ?= go
4-
GOLANGCI_LINT ?= golangci-lint
3+
GOLANGCI_LINT_VERSION ?= v1.48.0
54

6-
.PHONY: $(VENDORDIR) lint test test-unit
5+
GO ?= go
6+
GOLANGCI_LINT ?= $(shell go env GOPATH)/bin/golangci-lint-$(GOLANGCI_LINT_VERSION)
77

8-
$(VENDORDIR):
9-
@mkdir -p $(VENDORDIR)
8+
.PHONY: $(VENDOR_DIR)
9+
$(VENDOR_DIR):
10+
@mkdir -p $(VENDOR_DIR)
1011
@$(GO) mod vendor
1112

12-
lint:
13-
@$(GOLANGCI_LINT) run
13+
.PHONY: lint
14+
lint: $(GOLANGCI_LINT) $(VENDOR_DIR)
15+
@$(GOLANGCI_LINT) run -c .golangci.yaml
1416

17+
.PHONY: test
1518
test: test-unit
1619

1720
## Run unit tests
21+
.PHONY: test-unit
1822
test-unit:
1923
@echo ">> unit test"
2024
@$(GO) test -gcflags=-l -coverprofile=unit.coverprofile -covermode=atomic -race ./...
25+
26+
.PHONY: golangci-lint-version
27+
golangci-lint-version:
28+
@echo "::set-output name=GOLANGCI_LINT_VERSION::$(GOLANGCI_LINT_VERSION)"
29+
30+
$(GOLANGCI_LINT):
31+
@echo "$(OK_COLOR)==> Installing golangci-lint $(GOLANGCI_LINT_VERSION)$(NO_COLOR)"; \
32+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./bin "$(GOLANGCI_LINT_VERSION)"
33+
@mv ./bin/golangci-lint $(GOLANGCI_LINT)

README.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,35 @@
33
[![GitHub Releases](https://img.shields.io/github/v/release/nhatthm/surveyexpect)](https://github.com/nhatthm/surveyexpect/releases/latest)
44
[![Build Status](https://github.com/nhatthm/surveyexpect/actions/workflows/test.yaml/badge.svg)](https://github.com/nhatthm/surveyexpect/actions/workflows/test.yaml)
55
[![codecov](https://codecov.io/gh/nhatthm/surveyexpect/branch/master/graph/badge.svg?token=eTdAgDE2vR)](https://codecov.io/gh/nhatthm/surveyexpect)
6-
[![Go Report Card](https://goreportcard.com/badge/github.com/nhatthm/surveyexpect)](https://goreportcard.com/report/github.com/nhatthm/surveyexpect)
7-
[![GoDevDoc](https://img.shields.io/badge/dev-doc-00ADD8?logo=go)](https://pkg.go.dev/github.com/nhatthm/surveyexpect)
6+
[![Go Report Card](https://goreportcard.com/badge/go.nhat.io/surveyexpect)](https://goreportcard.com/report/go.nhat.io/surveyexpect)
7+
[![GoDevDoc](https://img.shields.io/badge/dev-doc-00ADD8?logo=go)](https://pkg.go.dev/go.nhat.io/surveyexpect)
88
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/donate/?hosted_button_id=PJZSGJN57TDJY)
99

1010
**surveyexpect** is an Expect library for [AlecAivazis/survey/v2](https://github.com/AlecAivazis/survey)
1111

1212
## Prerequisites
1313

14-
- `Go >= 1.16`
14+
- `Go >= 1.17`
1515

1616
## Install
1717

1818
```bash
19-
go get github.com/nhatthm/surveyexpect
19+
go get go.nhat.io/surveyexpect
2020
```
2121

2222
## Usage
2323

2424
### Supported Types
2525

26-
Type | Supported | Supported Actions
27-
:--- | :---: | :---
28-
`Confirm` | ✓ | <ul><li>Answer `yes`, `no` or a custom one</li><li>Interrupt (`^C`)</li><li>Ask for help</li></ul>
29-
`Editor` | ✘ | __*There is no plan for support*__
30-
`Input` | ✓ | <ul><li>Answer</li><li>No answer</li><li>Suggestions with navigation (Arrow Up ``, Arrow Down ``, Tab ``, Esc ``, Enter ``)</li><li>Interrupt (`^C`)</li><li>Ask for help</li></ul>
31-
`Multiline` | ✓ | <ul><li>Answer</li><li>No answer</li><li>Interrupt (`^C`)</li></ul>
32-
`Multiselect` | | <ul><li>Type to filter, delete</li><li>Navigation (Move Up ``, Move Down ``, Select None ``, Select All ``, Tab ``, Enter ``)</li><li>Interrupt (`^C`)</li><li>Ask for help</li></ul>
33-
`Password` | ✓ | <ul><li>Answer (+ check for `*`)</li><li>No answer</li><li>Interrupt (`^C`)</li><li>Ask for help</li></ul>
34-
`Select` | ✓ | <ul><li>Type to filter, delete</li><li>Navigation (Move Up ``, Move Down ``, Tab ``, Enter ``)</li><li>Interrupt (`^C`)</li><li>Ask for help</li></ul>
26+
| Type | Supported | Supported Actions |
27+
|:--------------|:---------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
28+
| `Confirm` || <ul><li>Answer `yes`, `no` or a custom one</li><li>Interrupt (`^C`)</li><li>Ask for help</li></ul> |
29+
| `Editor` || __*There is no plan for support*__ |
30+
| `Input` || <ul><li>Answer</li><li>No answer</li><li>Suggestions with navigation (Arrow Up ``, Arrow Down ``, Tab ``, Esc ``, Enter ``)</li><li>Interrupt (`^C`)</li><li>Ask for help</li></ul> |
31+
| `Multiline` || <ul><li>Answer</li><li>No answer</li><li>Interrupt (`^C`)</li></ul> |
32+
| `Multiselect` | | <ul><li>Type to filter, delete</li><li>Navigation (Move Up ``, Move Down ``, Select None ``, Select All ``, Tab ``, Enter ``)</li><li>Interrupt (`^C`)</li><li>Ask for help</li></ul> |
33+
| `Password` || <ul><li>Answer (+ check for `*`)</li><li>No answer</li><li>Interrupt (`^C`)</li><li>Ask for help</li></ul> |
34+
| `Select` || <ul><li>Type to filter, delete</li><li>Navigation (Move Up ``, Move Down ``, Tab ``, Enter ``)</li><li>Interrupt (`^C`)</li><li>Ask for help</li></ul> |
3535

3636
### Expect
3737

@@ -75,8 +75,8 @@ import (
7575

7676
"github.com/AlecAivazis/survey/v2"
7777
"github.com/AlecAivazis/survey/v2/terminal"
78-
"github.com/nhatthm/surveyexpect"
7978
"github.com/stretchr/testify/assert"
79+
"go.nhat.io/surveyexpect"
8080
)
8181

8282
func TestMyPackage(t *testing.T) {

buffer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type Buffer struct {
1414
// Write appends the contents of p to the buffer, growing the buffer as
1515
// needed. The return value n is the length of p; err is always nil. If the
1616
// buffer becomes too large, Write will panic with ErrTooLarge.
17-
func (b *Buffer) Write(p []byte) (n int, err error) {
17+
func (b *Buffer) Write(p []byte) (int, error) {
1818
b.mutex.Lock()
1919
defer b.mutex.Unlock()
2020

confirm.go

+12-11
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ type ConfirmPrompt struct {
2020

2121
// ShowHelp sets help for the expectation.
2222
//
23-
// Survey.ExpectConfirm("Are you sure to delete this file?").
24-
// ShowHelp("The file will be permanently deleted").
23+
// Survey.ExpectConfirm("Are you sure to delete this file?").
24+
// ShowHelp("The file will be permanently deleted").
2525
func (c *ConfirmPrompt) ShowHelp(help string, options ...string) {
2626
c.lock()
2727
defer c.unlock()
@@ -31,8 +31,8 @@ func (c *ConfirmPrompt) ShowHelp(help string, options ...string) {
3131

3232
// Interrupt marks the answer is interrupted.
3333
//
34-
// Survey.ExpectConfirm("Are you sure to delete this file?").
35-
// Interrupt().
34+
// Survey.ExpectConfirm("Are you sure to delete this file?").
35+
// Interrupt().
3636
func (c *ConfirmPrompt) Interrupt() {
3737
c.lock()
3838
defer c.unlock()
@@ -42,8 +42,8 @@ func (c *ConfirmPrompt) Interrupt() {
4242

4343
// Yes sets "yes" as the answer to the prompt.
4444
//
45-
// Survey.ExpectConfirm("Are you sure to delete this file?").
46-
// Yes().
45+
// Survey.ExpectConfirm("Are you sure to delete this file?").
46+
// Yes().
4747
func (c *ConfirmPrompt) Yes() {
4848
c.lock()
4949
defer c.unlock()
@@ -54,8 +54,8 @@ func (c *ConfirmPrompt) Yes() {
5454

5555
// No sets "no" as the answer to the prompt.
5656
//
57-
// Survey.ExpectConfirm("Are you sure to delete this file?").
58-
// No().
57+
// Survey.ExpectConfirm("Are you sure to delete this file?").
58+
// No().
5959
func (c *ConfirmPrompt) No() {
6060
c.lock()
6161
defer c.unlock()
@@ -67,10 +67,11 @@ func (c *ConfirmPrompt) No() {
6767
// Answer sets a custom answer to the prompt.
6868
//
6969
// If the answer is not not empty, the survey expects to have a feedback from the prompt:
70-
// `Sorry, your reply was invalid: "hello world!" is not a valid answer, please try again.`
7170
//
72-
// Survey.ExpectConfirm("Are you sure to delete this file?").
73-
// Answer("hello world!").
71+
// `Sorry, your reply was invalid: "hello world!" is not a valid answer, please try again.`
72+
//
73+
// Survey.ExpectConfirm("Are you sure to delete this file?").
74+
// Answer("hello world!").
7475
func (c *ConfirmPrompt) Answer(answer string) *ConfirmAnswer {
7576
c.lock()
7677
defer c.unlock()

confirm_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"github.com/AlecAivazis/survey/v2/terminal"
99
"github.com/stretchr/testify/assert"
1010

11-
"github.com/nhatthm/surveyexpect"
12-
"github.com/nhatthm/surveyexpect/options"
11+
"go.nhat.io/surveyexpect"
12+
"go.nhat.io/surveyexpect/options"
1313
)
1414

1515
func TestConfirm(t *testing.T) {

cursor_windows.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build windows
12
// +build windows
23

34
package surveyexpect

expect_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package surveyexpect_test
33
import (
44
"fmt"
55

6-
"github.com/nhatthm/surveyexpect"
6+
"go.nhat.io/surveyexpect"
77
)
88

99
type TestingT struct {

expectation.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ func expectMultiSelect(options ...string) *MultiSelectExpect {
7070
return &e
7171
}
7272

73-
func breakdownOptions(options []string, indicator *regexp.Regexp) (breakdown []map[string]string, pad string) {
74-
breakdown = make([]map[string]string, 0, len(options))
73+
func breakdownOptions(options []string, indicator *regexp.Regexp) ([]map[string]string, string) {
74+
breakdown := make([]map[string]string, 0, len(options))
7575

7676
var size int
7777

go.mod

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module github.com/nhatthm/surveyexpect
1+
module go.nhat.io/surveyexpect
22

33
go 1.17
44

@@ -13,12 +13,12 @@ require (
1313
require (
1414
github.com/davecgh/go-spew v1.1.1 // indirect
1515
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
16-
github.com/mattn/go-colorable v0.1.12 // indirect
17-
github.com/mattn/go-isatty v0.0.14 // indirect
16+
github.com/mattn/go-colorable v0.1.13 // indirect
17+
github.com/mattn/go-isatty v0.0.16 // indirect
1818
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
1919
github.com/pmezard/go-difflib v1.0.0 // indirect
20-
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 // indirect
21-
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
20+
golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64 // indirect
21+
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 // indirect
2222
golang.org/x/text v0.3.7 // indirect
2323
gopkg.in/yaml.v3 v3.0.1 // indirect
2424
)

go.sum

+9-9
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ github.com/hinshun/vt10x v0.0.0-20220301184237-5011da428d02/go.mod h1:Q48J4R4Dvx
1414
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
1515
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
1616
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
17-
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
18-
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
17+
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
18+
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
1919
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
20-
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
21-
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
20+
github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=
21+
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
2222
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
2323
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI=
2424
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
@@ -33,13 +33,13 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
3333
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
3434
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
3535
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
36-
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
37-
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
38-
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 h1:xHms4gcpe1YE7A3yIllJXP16CMAGuqwO2lX1mTyyRRc=
3936
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
37+
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
38+
golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64 h1:UiNENfZ8gDvpiWw7IpOMQ27spWmThO1RwwdQVbJahJM=
39+
golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
4040
golang.org/x/term v0.0.0-20210503060354-a79de5458b56/go.mod h1:tfny5GFUkzUvx4ps4ajbZsCe5lw1metzhBm9T3x7oIY=
41-
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
42-
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
41+
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 h1:Q5284mrmYTpACcm+eAKjKJH48BBwSyfJqmmGDTtT8Vc=
42+
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
4343
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
4444
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
4545
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=

0 commit comments

Comments
 (0)