-
Notifications
You must be signed in to change notification settings - Fork 18
/
suggest.go
36 lines (33 loc) · 885 Bytes
/
suggest.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package batchdl
import (
"github.com/c-bata/go-prompt"
"github.com/sagan/ptool/cmd"
"github.com/sagan/ptool/cmd/common"
"github.com/sagan/ptool/cmd/shell/suggest"
)
func init() {
cmd.AddShellCompletion("batchdl", func(document *prompt.Document) []prompt.Suggest {
info := suggest.Parse(document)
if info.LastArgIndex < 1 {
return nil
}
if info.LastArgIsFlag {
switch info.LastArgFlag {
case "action":
return suggest.EnumFlagArg(info.MatchingPrefix, ActionEnumFlag)
case "add-client":
return suggest.ClientArg(info.MatchingPrefix)
case "order":
return suggest.EnumFlagArg(info.MatchingPrefix, common.OrderFlag)
case "sort":
return suggest.EnumFlagArg(info.MatchingPrefix, common.SiteTorrentSortFlag)
default:
return nil
}
}
if info.LastArgIndex != 1 {
return nil
}
return suggest.SiteArg(info.MatchingPrefix)
})
}