Use variadic options to configure Kong.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package kong
|
||||
|
||||
import (
|
||||
"io"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
const defaultHelp = `{{- with .Application -}}
|
||||
usage: {{.Name}}
|
||||
|
||||
{{- end -}}
|
||||
`
|
||||
|
||||
var defaultHelpTemplate = template.Must(template.New("help").Parse(defaultHelp))
|
||||
|
||||
// WriteHelp to w. If w is nil, the default stdout writer will be used.
|
||||
func (k *Kong) WriteHelp(w io.Writer) error {
|
||||
if w == nil {
|
||||
w = k.stdout
|
||||
}
|
||||
ctx := map[string]interface{}{
|
||||
"Application": k.Model,
|
||||
}
|
||||
for k, v := range k.helpContext {
|
||||
ctx[k] = v
|
||||
}
|
||||
return k.help.Execute(w, ctx)
|
||||
}
|
||||
Reference in New Issue
Block a user