doc

package module
v0.0.0-...-8f5f0e7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2023 License: Apache-2.0 Imports: 8 Imported by: 1

README

Cobra documentation, from text/templates

This is an experimental piece of code to provide an idea of how we could generate Cobra's documentation using custom text/templates, as per this feature request.

Usage can be found in https://gist.github.com/jamietanna/020c15bbe5e6b258391fa3ded9861e38.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommandNameToMarkdownFilename

func CommandNameToMarkdownFilename(name string) string

func IsAvailableCommand

func IsAvailableCommand(c *cobra.Command) bool

IsAvailableCommand determines if a command is available as a non-help command (this includes all non hidden commands). Slightly modified version of https://pkg.go.dev/github.com/spf13/cobra#Command.IsAvailableCommand to work around https://github.com/spf13/cobra/issues/2032, and make it so deprecated commands are rendered

Types

type ChildCommand

type ChildCommand struct {
	Name  string
	Short string
}

type Command

type Command struct {
	Name       string
	Short      string
	Long       string
	Example    string
	Deprecated string
	Use        string

	NonInheritedFlags Flags
	InheritedFlags    Flags

	HasSeeAlso bool
	Parent     *ParentCommand
	Children   []ChildCommand
}

Command contains the single *cobra.Command's documentation and any relevant fields for documentation

func (Command) IsDeprecated

func (c Command) IsDeprecated() bool

type CommandDoc

type CommandDoc struct {
	Command Command
	Now     string
}

CommandDoc contains all metadata about a single *cobra.Command's documentation

func ParseCommand

func ParseCommand(cmd *cobra.Command) (CommandDoc, error)

type Flag

type Flag struct {
	Name                string
	Shorthand           string
	ShorthandDeprecated string
	Deprecated          string
	// Type references the type of variable the **??** TODO
	Type  string
	Usage string

	// DefaultValue corresponds with pflag's DefValue: default value (as text); for usage message
	DefaultValue string
	// DefaultValueIfNoOptionProvided corresponds with pflag's NoOptDefVal: default value (as text); if the flag is on the command line without any options
	DefaultValueIfNoOptionProvided string
}

func (Flag) NameAndShorthand

func (flag Flag) NameAndShorthand() string

type Flags

type Flags struct {
	Usage string
	Flags []Flag
}

type ParentCommand

type ParentCommand struct {
	Name  string
	Short string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL