package templates
import "k8s.io/kubectl/pkg/util/templates"
Index ¶
- Constants
- func Examples(s string) string
- func LongDesc(s string) string
- func MainHelpTemplate() string
- func MainUsageTemplate() string
- func Normalize(cmd *cobra.Command) *cobra.Command
- func NormalizeAll(cmd *cobra.Command) *cobra.Command
- func OptionsHelpTemplate() string
- func OptionsUsageTemplate() string
- func UseOptionsTemplates(cmd *cobra.Command)
- type ASCIIRenderer
- func (r *ASCIIRenderer) RenderFooter(w io.Writer, ast *blackfriday.Node)
- func (r *ASCIIRenderer) RenderHeader(w io.Writer, ast *blackfriday.Node)
- func (r *ASCIIRenderer) RenderNode(w io.Writer, node *blackfriday.Node, entering bool) blackfriday.WalkStatus
- type CommandGroup
- type CommandGroups
- func AddAdditionalCommands(g CommandGroups, message string, cmds []*cobra.Command) CommandGroups
- func (g CommandGroups) Add(c *cobra.Command)
- func (g CommandGroups) Has(c *cobra.Command) bool
- type FlagExposer
- type HelpFlagPrinter
Constants ¶
const ( SectionVars = `{{$isRootCmd := isRootCmd .}}` + `{{$rootCmd := rootCmd .}}` + `{{$visibleFlags := visibleFlags (flagsNotIntersected .LocalFlags .PersistentFlags)}}` + `{{$explicitlyExposedFlags := exposed .}}` + `{{$optionsCmdFor := optionsCmdFor .}}` + `{{$usageLine := usageLine .}}` + `{{$reverseParentsNames := reverseParentsNames .}}` SectionAliases = `{{if gt .Aliases 0}}Aliases: {{.NameAndAliases}} {{end}}` SectionExamples = `{{if .HasExample}}Examples: {{trimRight .Example}} {{end}}` SectionSubcommands = `{{if .HasAvailableSubCommands}}{{cmdGroupsString .}} {{end}}` SectionFlags = "" /* 300 byte string literal not displayed */ SectionUsage = `{{if and .Runnable (ne .UseLine "") (ne .UseLine $rootCmd)}}Usage: {{$usageLine}} {{end}}` SectionTipsHelp = "" /* 141 byte string literal not displayed */ SectionTipsGlobalOptions = `{{if $optionsCmdFor}}Use "{{$optionsCmdFor}}" for a list of global command-line options (applies to all commands). {{end}}` )
const Indentation = ` `
Functions ¶
func Examples ¶
Examples normalizes a command's examples to follow the conventions.
func LongDesc ¶
LongDesc normalizes a command's long description to follow the conventions.
func MainHelpTemplate ¶
func MainHelpTemplate() string
MainHelpTemplate if the template for 'help' used by most commands.
func MainUsageTemplate ¶
func MainUsageTemplate() string
MainUsageTemplate if the template for 'usage' used by most commands.
func Normalize ¶
Normalize perform all required normalizations on a given command.
func NormalizeAll ¶
NormalizeAll perform all required normalizations in the entire command tree.
func OptionsHelpTemplate ¶
func OptionsHelpTemplate() string
OptionsHelpTemplate if the template for 'help' used by the 'options' command.
func OptionsUsageTemplate ¶
func OptionsUsageTemplate() string
OptionsUsageTemplate if the template for 'usage' used by the 'options' command.
func UseOptionsTemplates ¶
Types ¶
type ASCIIRenderer ¶
type ASCIIRenderer struct { Indentation string // contains filtered or unexported fields }
ASCIIRenderer is a blackfriday.Renderer intended for rendering markdown documents as plain text, well suited for human reading on terminals.
func (*ASCIIRenderer) RenderFooter ¶
func (r *ASCIIRenderer) RenderFooter(w io.Writer, ast *blackfriday.Node)
RenderFooter writes document footer.
func (*ASCIIRenderer) RenderHeader ¶
func (r *ASCIIRenderer) RenderHeader(w io.Writer, ast *blackfriday.Node)
RenderHeader writes document preamble and TOC if requested.
func (*ASCIIRenderer) RenderNode ¶
func (r *ASCIIRenderer) RenderNode(w io.Writer, node *blackfriday.Node, entering bool) blackfriday.WalkStatus
render markdown to text
type CommandGroup ¶
type CommandGroups ¶
type CommandGroups []CommandGroup
func AddAdditionalCommands ¶
func AddAdditionalCommands(g CommandGroups, message string, cmds []*cobra.Command) CommandGroups
func (CommandGroups) Add ¶
func (g CommandGroups) Add(c *cobra.Command)
func (CommandGroups) Has ¶
func (g CommandGroups) Has(c *cobra.Command) bool
type FlagExposer ¶
type FlagExposer interface { ExposeFlags(cmd *cobra.Command, flags ...string) FlagExposer }
func ActsAsRootCommand ¶
func ActsAsRootCommand(cmd *cobra.Command, filters []string, groups ...CommandGroup) FlagExposer
type HelpFlagPrinter ¶
type HelpFlagPrinter struct {
// contains filtered or unexported fields
}
HelpFlagPrinter is a printer that processes the help flag and print it to i/o writer
func NewHelpFlagPrinter ¶
func NewHelpFlagPrinter(out io.Writer, wrapLimit uint) *HelpFlagPrinter
NewHelpFlagPrinter will initialize a HelpFlagPrinter given the i/o writer
func (*HelpFlagPrinter) PrintHelpFlag ¶
func (p *HelpFlagPrinter) PrintHelpFlag(flag *flag.Flag)
PrintHelpFlag will beautify the help flags and print it out to p.out
Source Files ¶
command_groups.go help_flags_printer.go markdown.go normalizers.go templater.go templates.go
- Version
- v0.32.3 (latest)
- Published
- Mar 12, 2025
- Platform
- linux/amd64
- Imports
- 12 packages
- Last checked
- 6 days ago –
Tools for package owners.