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
- func CommandExecution(data CommandData) string
- func CommandInitializer(data CommandData) *jen.File
- func CommandRegistration(data CommandData) *jen.File
- func SkeletonInternalVersion(modulePath string) *jen.File
- func SkeletonMain(modulePath string) *jen.File
- func SkeletonRoot(data SkeletonRootData) *jen.File
- type CommandData
- type CommandFlag
- type SkeletonRootData
- type SkeletonSubcommand
Constants ¶
const SkeletonConfig = `log:
level: info
`
const SkeletonGoMod = `` /* 185-byte string literal not displayed */
Variables ¶
This section is empty.
Functions ¶
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 ¶
SkeletonInternalVersion generates the internal/version/version.go file for scaffolded projects, mirroring gtb's own internal/version pattern.
func SkeletonMain ¶
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
Hashes map[string]string
}
type CommandFlag ¶
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
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.