aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/posener
diff options
context:
space:
mode:
authorNathan Dench <ndenc2@gmail.com>2019-05-24 15:16:44 +1000
committerNathan Dench <ndenc2@gmail.com>2019-05-24 15:16:44 +1000
commit107c1cdb09c575aa2f61d97f48d8587eb6bada4c (patch)
treeca7d008643efc555c388baeaf1d986e0b6b3e28c /vendor/github.com/posener
parent844b5a68d8af4791755b8f0ad293cc99f5959183 (diff)
downloadterraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.gz
terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.zst
terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.zip
Upgrade to 0.12
Diffstat (limited to 'vendor/github.com/posener')
-rw-r--r--vendor/github.com/posener/complete/.gitignore2
-rw-r--r--vendor/github.com/posener/complete/.travis.yml7
-rw-r--r--vendor/github.com/posener/complete/args.go9
-rw-r--r--vendor/github.com/posener/complete/cmd/cmd.go2
-rw-r--r--vendor/github.com/posener/complete/cmd/install/fish.go56
-rw-r--r--vendor/github.com/posener/complete/cmd/install/install.go29
-rw-r--r--vendor/github.com/posener/complete/cmd/install/utils.go24
-rw-r--r--vendor/github.com/posener/complete/complete.go30
-rw-r--r--vendor/github.com/posener/complete/go.mod3
-rw-r--r--vendor/github.com/posener/complete/go.sum4
-rw-r--r--vendor/github.com/posener/complete/log.go3
-rw-r--r--vendor/github.com/posener/complete/metalinter.json21
-rw-r--r--vendor/github.com/posener/complete/readme.md6
13 files changed, 156 insertions, 40 deletions
diff --git a/vendor/github.com/posener/complete/.gitignore b/vendor/github.com/posener/complete/.gitignore
index 1363720..293955f 100644
--- a/vendor/github.com/posener/complete/.gitignore
+++ b/vendor/github.com/posener/complete/.gitignore
@@ -1,2 +1,4 @@
1.idea 1.idea
2coverage.txt 2coverage.txt
3gocomplete/gocomplete
4example/self/self
diff --git a/vendor/github.com/posener/complete/.travis.yml b/vendor/github.com/posener/complete/.travis.yml
index c2798f8..2fae945 100644
--- a/vendor/github.com/posener/complete/.travis.yml
+++ b/vendor/github.com/posener/complete/.travis.yml
@@ -1,17 +1,16 @@
1language: go 1language: go
2sudo: false 2sudo: false
3go: 3go:
4 - 1.11
5 - 1.10.x
4 - 1.9 6 - 1.9
5 - 1.8 7 - 1.8
6 8
7before_install: 9before_install:
8 - go get -u -t ./... 10 - go get -u -t ./...
9 - go get -u gopkg.in/alecthomas/gometalinter.v1
10 - gometalinter.v1 --install
11 11
12script: 12script:
13 - gometalinter.v1 --config metalinter.json ./... 13 - GO111MODULE=on ./test.sh
14 - ./test.sh
15 14
16after_success: 15after_success:
17 - bash <(curl -s https://codecov.io/bash) 16 - bash <(curl -s https://codecov.io/bash)
diff --git a/vendor/github.com/posener/complete/args.go b/vendor/github.com/posener/complete/args.go
index 1ba4d69..17ab2c6 100644
--- a/vendor/github.com/posener/complete/args.go
+++ b/vendor/github.com/posener/complete/args.go
@@ -57,11 +57,20 @@ func newArgs(line string) Args {
57 } 57 }
58} 58}
59 59
60// splitFields returns a list of fields from the given command line.
61// If the last character is space, it appends an empty field in the end
62// indicating that the field before it was completed.
63// If the last field is of the form "a=b", it splits it to two fields: "a", "b",
64// So it can be completed.
60func splitFields(line string) []string { 65func splitFields(line string) []string {
61 parts := strings.Fields(line) 66 parts := strings.Fields(line)
67
68 // Add empty field if the last field was completed.
62 if len(line) > 0 && unicode.IsSpace(rune(line[len(line)-1])) { 69 if len(line) > 0 && unicode.IsSpace(rune(line[len(line)-1])) {
63 parts = append(parts, "") 70 parts = append(parts, "")
64 } 71 }
72
73 // Treat the last field if it is of the form "a=b"
65 parts = splitLastEqual(parts) 74 parts = splitLastEqual(parts)
66 return parts 75 return parts
67} 76}
diff --git a/vendor/github.com/posener/complete/cmd/cmd.go b/vendor/github.com/posener/complete/cmd/cmd.go
index 7137dee..b99fe52 100644
--- a/vendor/github.com/posener/complete/cmd/cmd.go
+++ b/vendor/github.com/posener/complete/cmd/cmd.go
@@ -103,7 +103,7 @@ func (f *CLI) AddFlags(flags *flag.FlagSet) {
103 fmt.Sprintf("Uninstall completion for %s command", f.Name)) 103 fmt.Sprintf("Uninstall completion for %s command", f.Name))
104 } 104 }
105 if flags.Lookup("y") == nil { 105 if flags.Lookup("y") == nil {
106 flags.BoolVar(&f.yes, "y", false, "Don't prompt user for typing 'yes'") 106 flags.BoolVar(&f.yes, "y", false, "Don't prompt user for typing 'yes' when installing completion")
107 } 107 }
108} 108}
109 109
diff --git a/vendor/github.com/posener/complete/cmd/install/fish.go b/vendor/github.com/posener/complete/cmd/install/fish.go
new file mode 100644
index 0000000..6467196
--- /dev/null
+++ b/vendor/github.com/posener/complete/cmd/install/fish.go
@@ -0,0 +1,56 @@
1package install
2
3import (
4 "bytes"
5 "fmt"
6 "os"
7 "path/filepath"
8 "text/template"
9)
10
11// (un)install in fish
12
13type fish struct {
14 configDir string
15}
16
17func (f fish) Install(cmd, bin string) error {
18 completionFile := filepath.Join(f.configDir, "completions", fmt.Sprintf("%s.fish", cmd))
19 completeCmd, err := f.cmd(cmd, bin)
20 if err != nil {
21 return err
22 }
23 if _, err := os.Stat(completionFile); err == nil {
24 return fmt.Errorf("already installed at %s", completionFile)
25 }
26
27 return createFile(completionFile, completeCmd)
28}
29
30func (f fish) Uninstall(cmd, bin string) error {
31 completionFile := filepath.Join(f.configDir, "completions", fmt.Sprintf("%s.fish", cmd))
32 if _, err := os.Stat(completionFile); err != nil {
33 return fmt.Errorf("does not installed in %s", f.configDir)
34 }
35
36 return os.Remove(completionFile)
37}
38
39func (f fish) cmd(cmd, bin string) (string, error) {
40 var buf bytes.Buffer
41 params := struct{ Cmd, Bin string }{cmd, bin}
42 tmpl := template.Must(template.New("cmd").Parse(`
43function __complete_{{.Cmd}}
44 set -lx COMP_LINE (string join ' ' (commandline -o))
45 test (commandline -ct) = ""
46 and set COMP_LINE "$COMP_LINE "
47 {{.Bin}}
48end
49complete -c {{.Cmd}} -a "(__complete_{{.Cmd}})"
50`))
51 err := tmpl.Execute(&buf, params)
52 if err != nil {
53 return "", err
54 }
55 return buf.String(), nil
56}
diff --git a/vendor/github.com/posener/complete/cmd/install/install.go b/vendor/github.com/posener/complete/cmd/install/install.go
index 082a226..dfa1963 100644
--- a/vendor/github.com/posener/complete/cmd/install/install.go
+++ b/vendor/github.com/posener/complete/cmd/install/install.go
@@ -51,7 +51,7 @@ func Uninstall(cmd string) error {
51 for _, i := range is { 51 for _, i := range is {
52 errI := i.Uninstall(cmd, bin) 52 errI := i.Uninstall(cmd, bin)
53 if errI != nil { 53 if errI != nil {
54 multierror.Append(err, errI) 54 err = multierror.Append(err, errI)
55 } 55 }
56 } 56 }
57 57
@@ -68,9 +68,36 @@ func installers() (i []installer) {
68 if f := rcFile(".zshrc"); f != "" { 68 if f := rcFile(".zshrc"); f != "" {
69 i = append(i, zsh{f}) 69 i = append(i, zsh{f})
70 } 70 }
71 if d := fishConfigDir(); d != "" {
72 i = append(i, fish{d})
73 }
71 return 74 return
72} 75}
73 76
77func fishConfigDir() string {
78 configDir := filepath.Join(getConfigHomePath(), "fish")
79 if configDir == "" {
80 return ""
81 }
82 if info, err := os.Stat(configDir); err != nil || !info.IsDir() {
83 return ""
84 }
85 return configDir
86}
87
88func getConfigHomePath() string {
89 u, err := user.Current()
90 if err != nil {
91 return ""
92 }
93
94 configHome := os.Getenv("XDG_CONFIG_HOME")
95 if configHome == "" {
96 return filepath.Join(u.HomeDir, ".config")
97 }
98 return configHome
99}
100
74func getBinaryPath() (string, error) { 101func getBinaryPath() (string, error) {
75 bin, err := os.Executable() 102 bin, err := os.Executable()
76 if err != nil { 103 if err != nil {
diff --git a/vendor/github.com/posener/complete/cmd/install/utils.go b/vendor/github.com/posener/complete/cmd/install/utils.go
index 2c8b44c..d34ac8c 100644
--- a/vendor/github.com/posener/complete/cmd/install/utils.go
+++ b/vendor/github.com/posener/complete/cmd/install/utils.go
@@ -6,6 +6,7 @@ import (
6 "io" 6 "io"
7 "io/ioutil" 7 "io/ioutil"
8 "os" 8 "os"
9 "path/filepath"
9) 10)
10 11
11func lineInFile(name string, lookFor string) bool { 12func lineInFile(name string, lookFor string) bool {
@@ -36,6 +37,24 @@ func lineInFile(name string, lookFor string) bool {
36 } 37 }
37} 38}
38 39
40func createFile(name string, content string) error {
41 // make sure file directory exists
42 if err := os.MkdirAll(filepath.Dir(name), 0775); err != nil {
43 return err
44 }
45
46 // create the file
47 f, err := os.Create(name)
48 if err != nil {
49 return err
50 }
51 defer f.Close()
52
53 // write file content
54 _, err = f.WriteString(fmt.Sprintf("%s\n", content))
55 return err
56}
57
39func appendToFile(name string, content string) error { 58func appendToFile(name string, content string) error {
40 f, err := os.OpenFile(name, os.O_RDWR|os.O_APPEND, 0) 59 f, err := os.OpenFile(name, os.O_RDWR|os.O_APPEND, 0)
41 if err != nil { 60 if err != nil {
@@ -96,7 +115,10 @@ func removeContentToTempFile(name, content string) (string, error) {
96 if str == content { 115 if str == content {
97 continue 116 continue
98 } 117 }
99 wf.WriteString(str + "\n") 118 _, err = wf.WriteString(str + "\n")
119 if err != nil {
120 return "", err
121 }
100 prefix = prefix[:0] 122 prefix = prefix[:0]
101 } 123 }
102 return wf.Name(), nil 124 return wf.Name(), nil
diff --git a/vendor/github.com/posener/complete/complete.go b/vendor/github.com/posener/complete/complete.go
index 185d1e8..725c4de 100644
--- a/vendor/github.com/posener/complete/complete.go
+++ b/vendor/github.com/posener/complete/complete.go
@@ -10,14 +10,16 @@ import (
10 "fmt" 10 "fmt"
11 "io" 11 "io"
12 "os" 12 "os"
13 "strconv"
13 14
14 "github.com/posener/complete/cmd" 15 "github.com/posener/complete/cmd"
15 "github.com/posener/complete/match" 16 "github.com/posener/complete/match"
16) 17)
17 18
18const ( 19const (
19 envComplete = "COMP_LINE" 20 envLine = "COMP_LINE"
20 envDebug = "COMP_DEBUG" 21 envPoint = "COMP_POINT"
22 envDebug = "COMP_DEBUG"
21) 23)
22 24
23// Complete structs define completion for a command with CLI options 25// Complete structs define completion for a command with CLI options
@@ -55,13 +57,18 @@ func (c *Complete) Run() bool {
55// For installation: it assumes that flags were added and parsed before 57// For installation: it assumes that flags were added and parsed before
56// it was called. 58// it was called.
57func (c *Complete) Complete() bool { 59func (c *Complete) Complete() bool {
58 line, ok := getLine() 60 line, point, ok := getEnv()
59 if !ok { 61 if !ok {
60 // make sure flags parsed, 62 // make sure flags parsed,
61 // in case they were not added in the main program 63 // in case they were not added in the main program
62 return c.CLI.Run() 64 return c.CLI.Run()
63 } 65 }
64 Log("Completing line: %s", line) 66
67 if point >= 0 && point < len(line) {
68 line = line[:point]
69 }
70
71 Log("Completing phrase: %s", line)
65 a := newArgs(line) 72 a := newArgs(line)
66 Log("Completing last field: %s", a.Last) 73 Log("Completing last field: %s", a.Last)
67 options := c.Command.Predict(a) 74 options := c.Command.Predict(a)
@@ -79,12 +86,19 @@ func (c *Complete) Complete() bool {
79 return true 86 return true
80} 87}
81 88
82func getLine() (string, bool) { 89func getEnv() (line string, point int, ok bool) {
83 line := os.Getenv(envComplete) 90 line = os.Getenv(envLine)
84 if line == "" { 91 if line == "" {
85 return "", false 92 return
93 }
94 point, err := strconv.Atoi(os.Getenv(envPoint))
95 if err != nil {
96 // If failed parsing point for some reason, set it to point
97 // on the end of the line.
98 Log("Failed parsing point %s: %v", os.Getenv(envPoint), err)
99 point = len(line)
86 } 100 }
87 return line, true 101 return line, point, true
88} 102}
89 103
90func (c *Complete) output(options []string) { 104func (c *Complete) output(options []string) {
diff --git a/vendor/github.com/posener/complete/go.mod b/vendor/github.com/posener/complete/go.mod
new file mode 100644
index 0000000..fef0c44
--- /dev/null
+++ b/vendor/github.com/posener/complete/go.mod
@@ -0,0 +1,3 @@
1module github.com/posener/complete
2
3require github.com/hashicorp/go-multierror v1.0.0
diff --git a/vendor/github.com/posener/complete/go.sum b/vendor/github.com/posener/complete/go.sum
new file mode 100644
index 0000000..d2f1330
--- /dev/null
+++ b/vendor/github.com/posener/complete/go.sum
@@ -0,0 +1,4 @@
1github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
2github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
3github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o=
4github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
diff --git a/vendor/github.com/posener/complete/log.go b/vendor/github.com/posener/complete/log.go
index 797a80c..c302955 100644
--- a/vendor/github.com/posener/complete/log.go
+++ b/vendor/github.com/posener/complete/log.go
@@ -1,7 +1,6 @@
1package complete 1package complete
2 2
3import ( 3import (
4 "io"
5 "io/ioutil" 4 "io/ioutil"
6 "log" 5 "log"
7 "os" 6 "os"
@@ -15,7 +14,7 @@ import (
15var Log = getLogger() 14var Log = getLogger()
16 15
17func getLogger() func(format string, args ...interface{}) { 16func getLogger() func(format string, args ...interface{}) {
18 var logfile io.Writer = ioutil.Discard 17 var logfile = ioutil.Discard
19 if os.Getenv(envDebug) != "" { 18 if os.Getenv(envDebug) != "" {
20 logfile = os.Stderr 19 logfile = os.Stderr
21 } 20 }
diff --git a/vendor/github.com/posener/complete/metalinter.json b/vendor/github.com/posener/complete/metalinter.json
deleted file mode 100644
index 799c1d0..0000000
--- a/vendor/github.com/posener/complete/metalinter.json
+++ /dev/null
@@ -1,21 +0,0 @@
1{
2 "Vendor": true,
3 "DisableAll": true,
4 "Enable": [
5 "gofmt",
6 "goimports",
7 "interfacer",
8 "goconst",
9 "misspell",
10 "unconvert",
11 "gosimple",
12 "golint",
13 "structcheck",
14 "deadcode",
15 "vet"
16 ],
17 "Exclude": [
18 "initTests is unused"
19 ],
20 "Deadline": "2m"
21}
diff --git a/vendor/github.com/posener/complete/readme.md b/vendor/github.com/posener/complete/readme.md
index 74077e3..6d757ef 100644
--- a/vendor/github.com/posener/complete/readme.md
+++ b/vendor/github.com/posener/complete/readme.md
@@ -1,12 +1,13 @@
1# complete 1# complete
2 2
3A tool for bash writing bash completion in go, and bash completion for the go command line.
4
3[![Build Status](https://travis-ci.org/posener/complete.svg?branch=master)](https://travis-ci.org/posener/complete) 5[![Build Status](https://travis-ci.org/posener/complete.svg?branch=master)](https://travis-ci.org/posener/complete)
4[![codecov](https://codecov.io/gh/posener/complete/branch/master/graph/badge.svg)](https://codecov.io/gh/posener/complete) 6[![codecov](https://codecov.io/gh/posener/complete/branch/master/graph/badge.svg)](https://codecov.io/gh/posener/complete)
7[![golangci](https://golangci.com/badges/github.com/posener/complete.svg)](https://golangci.com/r/github.com/posener/complete)
5[![GoDoc](https://godoc.org/github.com/posener/complete?status.svg)](http://godoc.org/github.com/posener/complete) 8[![GoDoc](https://godoc.org/github.com/posener/complete?status.svg)](http://godoc.org/github.com/posener/complete)
6[![Go Report Card](https://goreportcard.com/badge/github.com/posener/complete)](https://goreportcard.com/report/github.com/posener/complete) 9[![Go Report Card](https://goreportcard.com/badge/github.com/posener/complete)](https://goreportcard.com/report/github.com/posener/complete)
7 10
8A tool for bash writing bash completion in go.
9
10Writing bash completion scripts is a hard work. This package provides an easy way 11Writing bash completion scripts is a hard work. This package provides an easy way
11to create bash completion scripts for any command, and also an easy way to install/uninstall 12to create bash completion scripts for any command, and also an easy way to install/uninstall
12the completion of the command. 13the completion of the command.
@@ -42,6 +43,7 @@ Supported shells:
42 43
43- [x] bash 44- [x] bash
44- [x] zsh 45- [x] zsh
46- [x] fish
45 47
46### Usage 48### Usage
47 49