commandsgen

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package commandsgen reads YAML command definitions and generates code from them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateCommandsCode

func GenerateCommandsCode(pkg string, contextType string, commands Commands) ([]byte, error)

func GenerateDocsFiles

func GenerateDocsFiles(commands Commands) (map[string][]byte, error)

Types

type Command

type Command struct {
	FullName               string `yaml:"name"`
	NamePath               []string
	Summary                string `yaml:"summary"`
	Description            string `yaml:"description"`
	DescriptionPlain       string
	DescriptionHighlighted string
	Deprecated             string   `yaml:"deprecated"`
	HasInit                bool     `yaml:"has-init"`
	ExactArgs              int      `yaml:"exact-args"`
	MaximumArgs            int      `yaml:"maximum-args"`
	IgnoreMissingEnv       bool     `yaml:"ignores-missing-env"`
	SubcommandsOptional    bool     `yaml:"subcommands-optional"`
	Options                []Option `yaml:"options"`
	OptionSets             []string `yaml:"option-sets"`
	Docs                   Docs     `yaml:"docs"`
}

Command represents the structure of each command in the commands map.

type Commands

type Commands struct {
	CommandList []Command    `yaml:"commands"`
	OptionSets  []OptionSets `yaml:"option-sets"`
}

Commands represents the top-level structure holding commands and option sets.

func ParseCommands

func ParseCommands(yamlDataList ...[]byte) (Commands, error)

ParseCommands parses command definitions from one or more YAML byte slices.

type Docs

type Docs struct {
	Keywords          []string `yaml:"keywords"`
	DescriptionHeader string   `yaml:"description-header"`
	Tags              []string `yaml:"tags"`
}

Docs represents docs-only information that is not used in CLI generation.

type Option

type Option struct {
	Name               string   `yaml:"name"`
	Type               string   `yaml:"type"`
	DisplayType        string   `yaml:"display-type"`
	Description        string   `yaml:"description"`
	Deprecated         string   `yaml:"deprecated"`
	Short              string   `yaml:"short,omitempty"`
	Default            string   `yaml:"default,omitempty"`
	ImpliedEnv         string   `yaml:"implied-env,omitempty"`
	Required           bool     `yaml:"required,omitempty"`
	Aliases            []string `yaml:"aliases,omitempty"`
	EnumValues         []string `yaml:"enum-values,omitempty"`
	Experimental       bool     `yaml:"experimental,omitempty"`
	Hidden             bool     `yaml:"hidden,omitempty"`
	HiddenLegacyValues []string `yaml:"hidden-legacy-values,omitempty"`
}

Option represents the structure of an option within option sets.

type OptionSets

type OptionSets struct {
	Name            string   `yaml:"name"`
	Description     string   `yaml:"description"`
	Options         []Option `yaml:"options"`
	ExternalPackage string   `yaml:"external-package"`
}

OptionSets represents the structure of option sets.

Jump to

Keyboard shortcuts

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