mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-23 22:27:38 -05:00
6fde3632ef
The vendor/ folder was created with the help of @FiloSottile's gvt and vendorcheck. Any dependencies of Caddy plugins outside this repo are not vendored. We do not remove any unused, vendored packages because vendorcheck -u only checks using the current build configuration; i.e. packages that may be imported by files toggled by build tags of other systems. CI tests have been updated to ignore the vendor/ folder. When Go 1.9 is released, a few of the go commands should be revised to again use ./... as it will ignore the vendor folder by default.
33 lines
903 B
Go
33 lines
903 B
Go
package kingpin
|
|
|
|
// HintAction is a function type who is expected to return a slice of possible
|
|
// command line arguments.
|
|
type HintAction func() []string
|
|
type completionsMixin struct {
|
|
hintActions []HintAction
|
|
builtinHintActions []HintAction
|
|
}
|
|
|
|
func (a *completionsMixin) addHintAction(action HintAction) {
|
|
a.hintActions = append(a.hintActions, action)
|
|
}
|
|
|
|
// Allow adding of HintActions which are added internally, ie, EnumVar
|
|
func (a *completionsMixin) addHintActionBuiltin(action HintAction) {
|
|
a.builtinHintActions = append(a.builtinHintActions, action)
|
|
}
|
|
|
|
func (a *completionsMixin) resolveCompletions() []string {
|
|
var hints []string
|
|
|
|
options := a.builtinHintActions
|
|
if len(a.hintActions) > 0 {
|
|
// User specified their own hintActions. Use those instead.
|
|
options = a.hintActions
|
|
}
|
|
|
|
for _, hintAction := range options {
|
|
hints = append(hints, hintAction()...)
|
|
}
|
|
return hints
|
|
}
|