only render template if needed i guess?
This commit is contained in:
parent
c622ba72be
commit
20a2befa34
|
@ -80,4 +80,12 @@ var TemplateFuncs = template.FuncMap{
|
||||||
}
|
}
|
||||||
|
|
||||||
// TemplateCommandHelp holds a template for rendering command help.
|
// TemplateCommandHelp holds a template for rendering command help.
|
||||||
var TemplateCommandHelp = template.Must(template.New("help").Funcs(TemplateFuncs).Parse(helpTemplateText))
|
var TemplateCommandHelp *template.Template
|
||||||
|
|
||||||
|
func HelpTemplate() *template.Template {
|
||||||
|
if TemplateCommandHelp == nil {
|
||||||
|
TemplateCommandHelp = template.Must(template.New("help").Funcs(TemplateFuncs).Parse(helpTemplateText))
|
||||||
|
}
|
||||||
|
|
||||||
|
return TemplateCommandHelp
|
||||||
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ func (cmd *Command) ShowHelp(globalOptions Options, args []string) ([]byte, erro
|
||||||
GlobalOptions: globalOptions,
|
GlobalOptions: globalOptions,
|
||||||
HTMLOutput: runtime.UnstyledHelpEnabled(),
|
HTMLOutput: runtime.UnstyledHelpEnabled(),
|
||||||
}
|
}
|
||||||
err := _c.TemplateCommandHelp.Execute(&buf, c)
|
err := _c.HelpTemplate().Execute(&buf, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue