updated GHA
Some checks reported errors
continuous-integration/drone/pr Build encountered an error
continuous-integration/drone/push Build encountered an error

Update to v2 SDK
updated dependencies
This commit is contained in:
2022-08-06 16:21:18 +02:00
parent 989e7079a5
commit e1266ebf64
1909 changed files with 122367 additions and 279095 deletions

View File

@ -1,4 +1,2 @@
.idea
coverage.txt
gocomplete/gocomplete
example/self/self

View File

@ -1,16 +1,17 @@
language: go
sudo: false
go:
- 1.11
- 1.10.x
- 1.9
- 1.8
before_install:
- go get -u -t ./...
- go get -u gopkg.in/alecthomas/gometalinter.v1
- gometalinter.v1 --install
script:
- GO111MODULE=on ./test.sh
- gometalinter.v1 --config metalinter.json ./...
- ./test.sh
after_success:
- bash <(curl -s https://codecov.io/bash)

View File

@ -57,20 +57,11 @@ func newArgs(line string) Args {
}
}
// splitFields returns a list of fields from the given command line.
// If the last character is space, it appends an empty field in the end
// indicating that the field before it was completed.
// If the last field is of the form "a=b", it splits it to two fields: "a", "b",
// So it can be completed.
func splitFields(line string) []string {
parts := strings.Fields(line)
// Add empty field if the last field was completed.
if len(line) > 0 && unicode.IsSpace(rune(line[len(line)-1])) {
parts = append(parts, "")
}
// Treat the last field if it is of the form "a=b"
parts = splitLastEqual(parts)
return parts
}

View File

@ -103,7 +103,7 @@ func (f *CLI) AddFlags(flags *flag.FlagSet) {
fmt.Sprintf("Uninstall completion for %s command", f.Name))
}
if flags.Lookup("y") == nil {
flags.BoolVar(&f.yes, "y", false, "Don't prompt user for typing 'yes' when installing completion")
flags.BoolVar(&f.yes, "y", false, "Don't prompt user for typing 'yes'")
}
}

View File

@ -16,10 +16,7 @@ type fish struct {
func (f fish) Install(cmd, bin string) error {
completionFile := filepath.Join(f.configDir, "completions", fmt.Sprintf("%s.fish", cmd))
completeCmd, err := f.cmd(cmd, bin)
if err != nil {
return err
}
completeCmd := f.cmd(cmd, bin)
if _, err := os.Stat(completionFile); err == nil {
return fmt.Errorf("already installed at %s", completionFile)
}
@ -36,10 +33,10 @@ func (f fish) Uninstall(cmd, bin string) error {
return os.Remove(completionFile)
}
func (f fish) cmd(cmd, bin string) (string, error) {
func (f fish) cmd(cmd, bin string) string {
var buf bytes.Buffer
params := struct{ Cmd, Bin string }{cmd, bin}
tmpl := template.Must(template.New("cmd").Parse(`
template.Must(template.New("cmd").Parse(`
function __complete_{{.Cmd}}
set -lx COMP_LINE (string join ' ' (commandline -o))
test (commandline -ct) = ""
@ -47,10 +44,7 @@ function __complete_{{.Cmd}}
{{.Bin}}
end
complete -c {{.Cmd}} -a "(__complete_{{.Cmd}})"
`))
err := tmpl.Execute(&buf, params)
if err != nil {
return "", err
}
return buf.String(), nil
`)).Execute(&buf, params)
return string(buf.Bytes())
}

View File

@ -51,7 +51,7 @@ func Uninstall(cmd string) error {
for _, i := range is {
errI := i.Uninstall(cmd, bin)
if errI != nil {
err = multierror.Append(err, errI)
multierror.Append(err, errI)
}
}

View File

@ -115,10 +115,7 @@ func removeContentToTempFile(name, content string) (string, error) {
if str == content {
continue
}
_, err = wf.WriteString(str + "\n")
if err != nil {
return "", err
}
wf.WriteString(str + "\n")
prefix = prefix[:0]
}
return wf.Name(), nil

View File

@ -10,16 +10,14 @@ import (
"fmt"
"io"
"os"
"strconv"
"github.com/posener/complete/cmd"
"github.com/posener/complete/match"
)
const (
envLine = "COMP_LINE"
envPoint = "COMP_POINT"
envDebug = "COMP_DEBUG"
envComplete = "COMP_LINE"
envDebug = "COMP_DEBUG"
)
// Complete structs define completion for a command with CLI options
@ -57,18 +55,13 @@ func (c *Complete) Run() bool {
// For installation: it assumes that flags were added and parsed before
// it was called.
func (c *Complete) Complete() bool {
line, point, ok := getEnv()
line, ok := getLine()
if !ok {
// make sure flags parsed,
// in case they were not added in the main program
return c.CLI.Run()
}
if point >= 0 && point < len(line) {
line = line[:point]
}
Log("Completing phrase: %s", line)
Log("Completing line: %s", line)
a := newArgs(line)
Log("Completing last field: %s", a.Last)
options := c.Command.Predict(a)
@ -86,19 +79,12 @@ func (c *Complete) Complete() bool {
return true
}
func getEnv() (line string, point int, ok bool) {
line = os.Getenv(envLine)
func getLine() (string, bool) {
line := os.Getenv(envComplete)
if line == "" {
return
return "", false
}
point, err := strconv.Atoi(os.Getenv(envPoint))
if err != nil {
// If failed parsing point for some reason, set it to point
// on the end of the line.
Log("Failed parsing point %s: %v", os.Getenv(envPoint), err)
point = len(line)
}
return line, point, true
return line, true
}
func (c *Complete) output(options []string) {

View File

@ -1,6 +1,7 @@
package complete
import (
"io"
"io/ioutil"
"log"
"os"
@ -14,7 +15,7 @@ import (
var Log = getLogger()
func getLogger() func(format string, args ...interface{}) {
var logfile = ioutil.Discard
var logfile io.Writer = ioutil.Discard
if os.Getenv(envDebug) != "" {
logfile = os.Stderr
}

21
vendor/github.com/posener/complete/metalinter.json generated vendored Normal file
View File

@ -0,0 +1,21 @@
{
"Vendor": true,
"DisableAll": true,
"Enable": [
"gofmt",
"goimports",
"interfacer",
"goconst",
"misspell",
"unconvert",
"gosimple",
"golint",
"structcheck",
"deadcode",
"vet"
],
"Exclude": [
"initTests is unused"
],
"Deadline": "2m"
}

View File

@ -4,7 +4,6 @@ A tool for bash writing bash completion in go, and bash completion for the go co
[![Build Status](https://travis-ci.org/posener/complete.svg?branch=master)](https://travis-ci.org/posener/complete)
[![codecov](https://codecov.io/gh/posener/complete/branch/master/graph/badge.svg)](https://codecov.io/gh/posener/complete)
[![golangci](https://golangci.com/badges/github.com/posener/complete.svg)](https://golangci.com/r/github.com/posener/complete)
[![GoDoc](https://godoc.org/github.com/posener/complete?status.svg)](http://godoc.org/github.com/posener/complete)
[![Go Report Card](https://goreportcard.com/badge/github.com/posener/complete)](https://goreportcard.com/report/github.com/posener/complete)