diff options
| author | Eyal Posener <[email protected]> | 2017-11-04 11:52:09 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-11-04 11:52:09 +0200 |
| commit | 00c86494ff7035cfd62f66042e9ca2b118b90122 (patch) | |
| tree | b507c4736c6f8de2e887e76b952961d1c8dcc44c /command.go | |
| parent | 88e59760adaddb8276c9b15511302890690e2dae (diff) | |
| parent | c45e6fe8516b89faca97fc3a485949a07a9530c7 (diff) | |
Merge pull request #53 from posener/finally-filter-matches
Filter matches as a final stage
Diffstat (limited to 'command.go')
| -rw-r--r-- | command.go | 17 |
1 files changed, 5 insertions, 12 deletions
@@ -1,7 +1,5 @@ package complete -import "github.com/posener/complete/match" - // Command represents a command line // It holds the data that enables auto completion of command line // Command can also be a sub command. @@ -25,9 +23,9 @@ type Command struct { } // Predict returns all possible predictions for args according to the command struct -func (c *Command) Predict(a Args) (predictions []string) { - predictions, _ = c.predict(a) - return +func (c *Command) Predict(a Args) []string { + options, _ := c.predict(a) + return options } // Commands is the type of Sub member, it maps a command name to a command struct @@ -36,9 +34,7 @@ type Commands map[string]Command // Predict completion of sub command names names according to command line arguments func (c Commands) Predict(a Args) (prediction []string) { for sub := range c { - if match.Prefix(sub, a.Last) { - prediction = append(prediction, sub) - } + prediction = append(prediction, sub) } return } @@ -56,10 +52,7 @@ func (f Flags) Predict(a Args) (prediction []string) { if flagHyphenStart && !lastHyphenStart { continue } - - if match.Prefix(flag, a.Last) { - prediction = append(prediction, flag) - } + prediction = append(prediction, flag) } return } |
