vendor complete library

This commit is contained in:
Alex Dadgar 2017-08-25 09:39:04 -07:00
parent cf09c2af24
commit 95c68156bc
2 changed files with 15 additions and 3 deletions

View file

@ -49,6 +49,14 @@ type Flags map[string]Predictor
// Predict completion of flags names according to command line arguments
func (f Flags) Predict(a Args) (prediction []string) {
for flag := range f {
// If the flag starts with a hyphen, we avoid emitting the prediction
// unless the last typed arg contains a hyphen as well.
flagHyphenStart := len(flag) != 0 && flag[0] == '-'
lastHyphenStart := len(a.Last) != 0 && a.Last[0] == '-'
if flagHyphenStart && !lastHyphenStart {
continue
}
if match.Prefix(flag, a.Last) {
prediction = append(prediction, flag)
}
@ -73,6 +81,10 @@ func (c *Command) predict(a Args) (options []string, only bool) {
if only {
return
}
// We matched so stop searching. Continuing to search can accidentally
// match a subcommand with current set of commands, see issue #46.
break
}
}

6
vendor/vendor.json vendored
View file

@ -1111,10 +1111,10 @@
"revisionTime": "2016-01-10T10:55:54Z"
},
{
"checksumSHA1": "6OEUkwOM0qgI6YxR+BDEn6YMvpU=",
"checksumSHA1": "rTNABfFJ9wtLQRH8uYNkEZGQOrY=",
"path": "github.com/posener/complete",
"revision": "e8d6fef54b6283f8bd3fbcb4a7de8884eb540293",
"revisionTime": "2017-05-27T17:24:47Z"
"revision": "2100d1b06c06462a8a47bfc41a7f24a5d60a1420",
"revisionTime": "2017-08-25T06:44:15Z"
},
{
"checksumSHA1": "NB7uVS0/BJDmNu68vPAlbrq4TME=",