Documentation
¶
Overview ¶
Package cmd provides reusable cobra commands
Index ¶
- func AddGroupedCommands(root *cobra.Command, group *cobra.Group, cmds ...*cobra.Command)
- func NewGendocsCmd(docs *embedutil.Documentation) *cobra.Command
- func NewGenschemaCmd(schemaDefs fs.FS, associations []SchemaAssociation) *cobra.Command
- func NewInfoCmd(docs *embedutil.Documentation) *cobra.Command
- func NewVersionCmd(info version.Info) *cobra.Command
- type SchemaAssociation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddGroupedCommands ¶
AddGroupedCommands is a helper function for adding command groups All commands will be added to root and associated with group
func NewGendocsCmd ¶
func NewGendocsCmd(docs *embedutil.Documentation) *cobra.Command
NewGendocsCmd creates a gendocs command group that allows tools to output embedded documentation in various formats
func NewGenschemaCmd ¶
func NewGenschemaCmd(schemaDefs fs.FS, associations []SchemaAssociation) *cobra.Command
NewGenschemaCmd creates the genschema command, which generates JSON Schema definitions.
The JSON Schema definitions must be made available in the schemaDefs fs.FS by embedding them. The go-common/pkg/genschema package provides the functionality to generate the JSON Schema definitions from Go types at build time.
The associations list is used to create a snippet of VS Code settings to enable YAML/JSON file validation using the generated schema definitions.
Example:
//go:embed schemas/* var schemaDefs embed.FS associations := []SchemaAssociation{ { Definition: "schemas/project-schema.json", FileMatch: []string{".act3-pt.yaml"}, }, { Definition: "schemas/template-shema.json", FileMatch: []string{".act3-template.yaml"}, }, } NewGenschemaCmd(schemaDefs, associations)
func NewInfoCmd ¶
func NewInfoCmd(docs *embedutil.Documentation) *cobra.Command
NewInfoCmd creates an info command that allows the viewing of embedded documentation in the terminal, converted to Markdown
Types ¶
type SchemaAssociation ¶
type SchemaAssociation struct { Definition string // Path to the schema definition FileMatch []string // List of filenames to validate with the schema }
SchemaAssociation associates a JSON Schema definition to the files it validates
Example:
associations := []SchemaAssociation{ { Definition: "project-schema.json", FileMatch: []string{".act3-pt.yaml"}, }, { Definition: "template-shema.json", FileMatch: []string{".act3-template.yaml"}, }, }