templates

package
v1.10.3 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package templates provides Go template definitions and data structures used by the generator to produce CLI command scaffolding, registration code (cmd.go), and implementation stubs (main.go). Template data types like CommandData carry the resolved configuration for each generated command.

Index

Constants

View Source
const SkeletonConfig = `log:
  level: info

server:
  grpc:
    reflection: true
`
View Source
const SkeletonGoMod = `` /* 282-byte string literal not displayed */

Variables

This section is empty.

Functions

func CommandConfigValidation added in v1.8.0

func CommandConfigValidation(data CommandData) string

CommandConfigValidation generates the content for a config.go file containing a Config struct stub and a ValidateConfig function for per-package schema validation.

func CommandExecution

func CommandExecution(data CommandData) string

func CommandInitializer

func CommandInitializer(data CommandData) *jen.File

func CommandRegistration

func CommandRegistration(data CommandData) *jen.File

func SkeletonInternalVersion

func SkeletonInternalVersion(modulePath string) *jen.File

SkeletonInternalVersion generates the internal/version/version.go file for scaffolded projects, mirroring gtb's own internal/version pattern.

func SkeletonMain

func SkeletonMain(modulePath string) *jen.File

SkeletonMain generates the cmd/<name>/main.go for scaffolded projects. It uses the internal/version package to retrieve version info and passes it to the root command constructor.

func SkeletonRoot

func SkeletonRoot(data SkeletonRootData) *jen.File

Types

type CommandData

type CommandData struct {
	Package                  string
	PascalName               string
	Name                     string
	Aliases                  []string
	Args                     string
	Short                    string
	Long                     string
	Hidden                   bool
	WithAssets               bool
	Flags                    []CommandFlag
	PersistentFlags          []CommandFlag
	AncestralPersistentFlags []CommandFlag
	MutuallyExclusive        [][]string
	RequiredTogether         [][]string
	Logic                    string
	Imports                  []string
	FullFileContent          string
	TestCode                 string
	Recommendations          []string
	PersistentPreRun         bool
	PreRun                   bool
	HasSubcommands           bool
	OmitRun                  bool
	WithInitializer          bool
	WithConfigValidation     bool
	Hashes                   map[string]string
}

type CommandFlag

type CommandFlag struct {
	Name          string
	Type          string
	Description   string
	Persistent    bool
	Shorthand     string
	Default       string
	DefaultIsCode bool
	Required      bool
	Hidden        bool
}

type SkeletonRootData

type SkeletonRootData struct {
	Name                  string
	Description           string
	ReleaseProvider       string
	Host                  string
	Org                   string
	RepoName              string
	Private               bool
	DisabledFeatures      []string
	EnabledFeatures       []string
	HelpType              string // "slack", "teams", or ""
	SlackChannel          string
	SlackTeam             string
	TeamsChannel          string
	TeamsTeam             string
	TelemetryEndpoint     string
	TelemetryOTelEndpoint string
	Subcommands           []SkeletonSubcommand
}

type SkeletonSubcommand

type SkeletonSubcommand struct {
	ImportPath  string // e.g. "github.com/org/repo/pkg/cmd/serve"
	PkgAlias    string // e.g. "serve"
	Constructor string // e.g. "NewCmdServe"
}

SkeletonSubcommand describes a top-level command that must be registered in the generated NewCmdRoot function.

Jump to

Keyboard shortcuts

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