summaryrefslogtreecommitdiff
path: root/command.go
diff options
context:
space:
mode:
authorEyal Posener <[email protected]>2017-05-06 19:47:27 +0300
committerEyal Posener <[email protected]>2017-05-06 19:51:33 +0300
commitdc4c327ae8cd5602ae10eeabde9bdf6fa5624286 (patch)
tree8ebacce9b6e90c650a0f0557426b5526abfe0705 /command.go
parent60345dc6db8d1247fef2fb456d2f18f3300651ac (diff)
Use local completion files and directories according to typed command
Diffstat (limited to 'command.go')
-rw-r--r--command.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/command.go b/command.go
index 7bc0fc5..fc0e28b 100644
--- a/command.go
+++ b/command.go
@@ -17,11 +17,11 @@ func (c *Command) options(args []string) (options []Option, only bool) {
// remove the first argument, which is the command name
args = args[1:]
-
+ last := last(args)
// if prev has something that needs to follow it,
// it is the most relevant completion
- if predicate, ok := c.Flags[last(args)]; ok && predicate != nil {
- return predicate.predict(), true
+ if predicate, ok := c.Flags[last]; ok && predicate != nil {
+ return predicate.predict(last), true
}
sub, options, only := c.searchSub(args)
@@ -41,7 +41,7 @@ func (c *Command) options(args []string) (options []Option, only bool) {
}
// add additional expected argument of the command
- options = append(options, c.Args.predict()...)
+ options = append(options, c.Args.predict(last)...)
return
}