Documentation ¶
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) AutoLink(out *bytes.Buffer, link []byte, kind int)
- func (r *ASCIIRenderer) BlockCode(out *bytes.Buffer, text []byte, lang string)
- func (r *ASCIIRenderer) BlockHtml(out *bytes.Buffer, text []byte)
- func (r *ASCIIRenderer) BlockQuote(out *bytes.Buffer, text []byte)
- func (r *ASCIIRenderer) CodeSpan(out *bytes.Buffer, text []byte)
- func (r *ASCIIRenderer) DocumentFooter(out *bytes.Buffer)
- func (r *ASCIIRenderer) DocumentHeader(out *bytes.Buffer)
- func (r *ASCIIRenderer) DoubleEmphasis(out *bytes.Buffer, text []byte)
- func (r *ASCIIRenderer) Emphasis(out *bytes.Buffer, text []byte)
- func (r *ASCIIRenderer) Entity(out *bytes.Buffer, entity []byte)
- func (r *ASCIIRenderer) FootnoteItem(out *bytes.Buffer, name, text []byte, flags int)
- func (r *ASCIIRenderer) FootnoteRef(out *bytes.Buffer, ref []byte, id int)
- func (r *ASCIIRenderer) Footnotes(out *bytes.Buffer, text func() bool)
- func (r *ASCIIRenderer) GetFlags() int
- func (r *ASCIIRenderer) HRule(out *bytes.Buffer)
- func (r *ASCIIRenderer) Header(out *bytes.Buffer, text func() bool, level int, id string)
- func (r *ASCIIRenderer) Image(out *bytes.Buffer, link []byte, title []byte, alt []byte)
- func (r *ASCIIRenderer) LineBreak(out *bytes.Buffer)
- func (r *ASCIIRenderer) Link(out *bytes.Buffer, link []byte, title []byte, content []byte)
- func (r *ASCIIRenderer) List(out *bytes.Buffer, text func() bool, flags int)
- func (r *ASCIIRenderer) ListItem(out *bytes.Buffer, text []byte, flags int)
- func (r *ASCIIRenderer) NormalText(out *bytes.Buffer, text []byte)
- func (r *ASCIIRenderer) Paragraph(out *bytes.Buffer, text func() bool)
- func (r *ASCIIRenderer) RawHtmlTag(out *bytes.Buffer, text []byte)
- func (r *ASCIIRenderer) Smartypants(out *bytes.Buffer, text []byte)
- func (r *ASCIIRenderer) StrikeThrough(out *bytes.Buffer, text []byte)
- func (r *ASCIIRenderer) Table(out *bytes.Buffer, header []byte, body []byte, columnData []int)
- func (r *ASCIIRenderer) TableCell(out *bytes.Buffer, text []byte, align int)
- func (r *ASCIIRenderer) TableHeaderCell(out *bytes.Buffer, text []byte, align int)
- func (r *ASCIIRenderer) TableRow(out *bytes.Buffer, text []byte)
- func (r *ASCIIRenderer) TitleBlock(out *bytes.Buffer, text []byte)
- func (r *ASCIIRenderer) TocFinalize()
- func (r *ASCIIRenderer) TocHeader(text []byte, level int)
- func (r *ASCIIRenderer) TocHeaderWithAnchor(text []byte, level int, anchor string)
- func (r *ASCIIRenderer) TripleEmphasis(out *bytes.Buffer, text []byte)
- type CommandGroup
- type CommandGroups
- type FlagExposer
Constants ¶
const ( // SectionVars is the help template section that declares variables to be used in the template. SectionVars = `{{$isRootCmd := isRootCmd .}}` + `{{$rootCmd := rootCmd .}}` + `{{$visibleFlags := visibleFlags (flagsNotIntersected .LocalFlags .PersistentFlags)}}` + `{{$explicitlyExposedFlags := exposed .}}` + `{{$optionsCmdFor := optionsCmdFor .}}` + `{{$usageLine := usageLine .}}` // SectionAliases is the help template section that displays command aliases. SectionAliases = `{{if gt .Aliases 0}}Aliases: {{.NameAndAliases}} {{end}}` // SectionExamples is the help template section that displays command examples. SectionExamples = `{{if .HasExample}}Examples: {{trimRight .Example}} {{end}}` // SectionSubcommands is the help template section that displays the command's subcommands. SectionSubcommands = `{{if .HasAvailableSubCommands}}{{cmdGroupsString .}} {{end}}` // SectionFlags is the help template section that displays the command's flags. SectionFlags = `` /* 260-byte string literal not displayed */ // SectionUsage is the help template section that displays the command's usage. SectionUsage = `{{if and .Runnable (ne .UseLine "") (ne .UseLine $rootCmd)}}Usage: {{$usageLine}} {{end}}` // SectionTipsHelp is the help template section that displays the '--help' hint. SectionTipsHelp = `{{if .HasSubCommands}}Use "{{$rootCmd}} <command> --help" for more information about a given command. {{end}}` // SectionTipsGlobalOptions is the help template section that displays the 'options' hint for displaying global flags. SectionTipsGlobalOptions = `{{if $optionsCmdFor}}Use "{{$optionsCmdFor}}" for a list of global command-line options (applies to all commands). {{end}}` )
const Indentation = ` `
Variables ¶
This section is empty.
Functions ¶
func LongDesc ¶ added in v1.5.1
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 NormalizeAll ¶ added in v1.5.1
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 ¶ added in v1.5.1
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) AutoLink ¶ added in v1.5.1
func (r *ASCIIRenderer) AutoLink(out *bytes.Buffer, link []byte, kind int)
func (*ASCIIRenderer) BlockCode ¶ added in v1.5.1
func (r *ASCIIRenderer) BlockCode(out *bytes.Buffer, text []byte, lang string)
BlockCode renders a chunk of text that represents source code.
func (*ASCIIRenderer) BlockHtml ¶ added in v1.5.1
func (r *ASCIIRenderer) BlockHtml(out *bytes.Buffer, text []byte)
func (*ASCIIRenderer) BlockQuote ¶ added in v1.5.1
func (r *ASCIIRenderer) BlockQuote(out *bytes.Buffer, text []byte)
func (*ASCIIRenderer) CodeSpan ¶ added in v1.5.1
func (r *ASCIIRenderer) CodeSpan(out *bytes.Buffer, text []byte)
func (*ASCIIRenderer) DocumentFooter ¶ added in v1.5.1
func (r *ASCIIRenderer) DocumentFooter(out *bytes.Buffer)
func (*ASCIIRenderer) DocumentHeader ¶ added in v1.5.1
func (r *ASCIIRenderer) DocumentHeader(out *bytes.Buffer)
func (*ASCIIRenderer) DoubleEmphasis ¶ added in v1.5.1
func (r *ASCIIRenderer) DoubleEmphasis(out *bytes.Buffer, text []byte)
func (*ASCIIRenderer) Emphasis ¶ added in v1.5.1
func (r *ASCIIRenderer) Emphasis(out *bytes.Buffer, text []byte)
func (*ASCIIRenderer) Entity ¶ added in v1.5.1
func (r *ASCIIRenderer) Entity(out *bytes.Buffer, entity []byte)
func (*ASCIIRenderer) FootnoteItem ¶ added in v1.5.1
func (r *ASCIIRenderer) FootnoteItem(out *bytes.Buffer, name, text []byte, flags int)
func (*ASCIIRenderer) FootnoteRef ¶ added in v1.5.1
func (r *ASCIIRenderer) FootnoteRef(out *bytes.Buffer, ref []byte, id int)
func (*ASCIIRenderer) Footnotes ¶ added in v1.5.1
func (r *ASCIIRenderer) Footnotes(out *bytes.Buffer, text func() bool)
func (*ASCIIRenderer) GetFlags ¶ added in v1.5.1
func (r *ASCIIRenderer) GetFlags() int
func (*ASCIIRenderer) HRule ¶ added in v1.5.1
func (r *ASCIIRenderer) HRule(out *bytes.Buffer)
func (*ASCIIRenderer) LineBreak ¶ added in v1.5.1
func (r *ASCIIRenderer) LineBreak(out *bytes.Buffer)
func (*ASCIIRenderer) List ¶ added in v1.5.1
func (r *ASCIIRenderer) List(out *bytes.Buffer, text func() bool, flags int)
List renders the start and end of a list.
func (*ASCIIRenderer) ListItem ¶ added in v1.5.1
func (r *ASCIIRenderer) ListItem(out *bytes.Buffer, text []byte, flags int)
ListItem renders list items and supports both ordered and unordered lists.
func (*ASCIIRenderer) NormalText ¶ added in v1.5.1
func (r *ASCIIRenderer) NormalText(out *bytes.Buffer, text []byte)
NormalText gets a text chunk *after* the markdown syntax was already processed and does a final cleanup on things we don't expect here, like removing linebreaks on things that are not a paragraph break (auto unwrap).
func (*ASCIIRenderer) Paragraph ¶ added in v1.5.1
func (r *ASCIIRenderer) Paragraph(out *bytes.Buffer, text func() bool)
Paragraph renders the start and end of a paragraph.
func (*ASCIIRenderer) RawHtmlTag ¶ added in v1.5.1
func (r *ASCIIRenderer) RawHtmlTag(out *bytes.Buffer, text []byte)
func (*ASCIIRenderer) Smartypants ¶ added in v1.5.1
func (r *ASCIIRenderer) Smartypants(out *bytes.Buffer, text []byte)
func (*ASCIIRenderer) StrikeThrough ¶ added in v1.5.1
func (r *ASCIIRenderer) StrikeThrough(out *bytes.Buffer, text []byte)
func (*ASCIIRenderer) TableCell ¶ added in v1.5.1
func (r *ASCIIRenderer) TableCell(out *bytes.Buffer, text []byte, align int)
func (*ASCIIRenderer) TableHeaderCell ¶ added in v1.5.1
func (r *ASCIIRenderer) TableHeaderCell(out *bytes.Buffer, text []byte, align int)
func (*ASCIIRenderer) TableRow ¶ added in v1.5.1
func (r *ASCIIRenderer) TableRow(out *bytes.Buffer, text []byte)
func (*ASCIIRenderer) TitleBlock ¶ added in v1.5.1
func (r *ASCIIRenderer) TitleBlock(out *bytes.Buffer, text []byte)
func (*ASCIIRenderer) TocFinalize ¶ added in v1.5.1
func (r *ASCIIRenderer) TocFinalize()
func (*ASCIIRenderer) TocHeader ¶ added in v1.5.1
func (r *ASCIIRenderer) TocHeader(text []byte, level int)
func (*ASCIIRenderer) TocHeaderWithAnchor ¶ added in v1.5.1
func (r *ASCIIRenderer) TocHeaderWithAnchor(text []byte, level int, anchor string)
func (*ASCIIRenderer) TripleEmphasis ¶ added in v1.5.1
func (r *ASCIIRenderer) TripleEmphasis(out *bytes.Buffer, text []byte)
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)
type FlagExposer ¶
type FlagExposer interface {
ExposeFlags(cmd *cobra.Command, flags ...string) FlagExposer
}
func ActsAsRootCommand ¶
func ActsAsRootCommand(cmd *cobra.Command, filters []string, groups ...CommandGroup) FlagExposer