diff options
| author | Eyal Posener <[email protected]> | 2017-08-25 09:44:15 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-08-25 09:44:15 +0300 |
| commit | 2100d1b06c06462a8a47bfc41a7f24a5d60a1420 (patch) | |
| tree | c475a9f6c7cae244a26bf01e6950cb8f59b494b3 /command.go | |
| parent | 5075f6d6e69fb7b5a20a79ca0b87b16a484e2d2a (diff) | |
| parent | 91e5b1f44aaf66170b8e890442035731cd4aa60d (diff) | |
Merge pull request #47 from dadgar/f-hide-flags
Allow restricting completion of flags
Diffstat (limited to 'command.go')
| -rw-r--r-- | command.go | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -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) } |
