generator

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultFileMode = 0o644
	DefaultDirMode  = 0o755
)

Variables

View Source
var (
	ErrNotGoToolBaseProject      = errors.New("the current project at '%s' is not a gtb project (.gtb/manifest.yaml not found)")
	ErrParentPathNotFound        = errors.New("parent path not found in manifest")
	ErrModuleNotFound            = errors.New("could not find module name in go.mod")
	ErrFuncNotFound              = errors.New("target function not found")
	ErrParentCommandFileNotFound = errors.New("parent command file not found")
)
View Source
var BreakingChanges = map[string]string{
	"v2.10.0": "Breaking changes to Assets interface and command signatures. Please refer to the migration guide.",
}

BreakingChanges is a map of version strings to descriptions of breaking changes introduced in that version. The keys should be valid semantic version strings (e.g., "v2.10.0"). The values are messages displayed to the user when they upgrade across these versions.

View Source
var ErrCommandProtected = errors.New("command is protected")
View Source
var ErrInvalidPackageName = errors.Newf("invalid package name")

Functions

func PascalCase

func PascalCase(s string) string

Types

type CommandFlag

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

type Config

type Config struct {
	Agentless        bool
	AIModel          string
	AIProvider       string
	Aliases          []string
	Args             string
	Flags            []string
	Force            bool
	Hidden           bool
	Long             string
	Name             string
	Parent           string
	Path             string
	PersistentPreRun bool
	PreRun           bool
	Prompt           string
	Protected        *bool
	ScriptPath       string
	Short            string
	UpdateDocs       bool
	WithAssets       bool
	WithInitializer  bool
}

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

func New

func New(p *props.Props, cfg *Config) *Generator

func (*Generator) FindCommandParentPath

func (g *Generator) FindCommandParentPath(name string) ([]string, error)

func (*Generator) Generate

func (g *Generator) Generate(ctx context.Context) error

func (*Generator) GenerateCommandFile

func (g *Generator) GenerateCommandFile(ctx context.Context, cmdDir string, data *templates.CommandData) error

func (*Generator) GenerateDocs

func (g *Generator) GenerateDocs(ctx context.Context, target string, isPackage bool) error

GenerateDocs generates documentation for the command or package.

func (*Generator) GenerateSkeleton

func (g *Generator) GenerateSkeleton(ctx context.Context, config SkeletonConfig) error

func (*Generator) RegenerateManifest

func (g *Generator) RegenerateManifest(ctx context.Context) error

func (*Generator) RegenerateProject

func (g *Generator) RegenerateProject(ctx context.Context) error

func (*Generator) Remove

func (g *Generator) Remove(ctx context.Context) error

func (*Generator) SetProtection

func (g *Generator) SetProtection(ctx context.Context, commandName string, protected bool) error

type Manifest

type Manifest struct {
	Properties    ManifestProperties    `yaml:"properties"`
	ReleaseSource ManifestReleaseSource `yaml:"release_source"`
	Version       ManifestVersion       `yaml:"version"`
	Commands      []ManifestCommand     `yaml:"commands,omitempty"`
}

func (*Manifest) GetReleaseSource

func (m *Manifest) GetReleaseSource() (sourceType, owner, repo string)

GetReleaseSource returns the release source type, owner, and repo.

type ManifestCommand

type ManifestCommand struct {
	Name              string            `yaml:"name"`
	Description       MultilineString   `yaml:"description"`
	LongDescription   MultilineString   `yaml:"long_description,omitempty"`
	Aliases           []string          `yaml:"aliases,omitempty"`
	Hidden            bool              `yaml:"hidden,omitempty"`
	Args              string            `yaml:"args,omitempty"`
	Hash              string            `yaml:"hash,omitempty"` // Deprecated: use Hashes
	Hashes            map[string]string `yaml:"hashes,omitempty"`
	WithAssets        bool              `yaml:"with_assets,omitempty"`
	Protected         *bool             `yaml:"protected,omitempty"`
	PersistentPreRun  bool              `yaml:"persistent_pre_run,omitempty"`
	PreRun            bool              `yaml:"pre_run,omitempty"`
	MutuallyExclusive [][]string        `yaml:"mutually_exclusive,omitempty"`
	RequiredTogether  [][]string        `yaml:"required_together,omitempty"`
	Flags             []ManifestFlag    `yaml:"flags,omitempty"`
	Commands          []ManifestCommand `yaml:"commands,omitempty"`
	Warning           string            `yaml:"-"` // Used for comments
}

func (ManifestCommand) MarshalYAML

func (c ManifestCommand) MarshalYAML() (any, error)

type ManifestFeature

type ManifestFeature struct {
	Name    string `yaml:"name"`
	Enabled bool   `yaml:"enabled"`
}

type ManifestFlag

type ManifestFlag struct {
	Name          string          `yaml:"name"`
	Type          string          `yaml:"type"`
	Description   MultilineString `yaml:"description"`
	Persistent    bool            `yaml:"persistent,omitempty"`
	Shorthand     string          `yaml:"shorthand,omitempty"`
	Default       string          `yaml:"default,omitempty"`
	DefaultIsCode bool            `yaml:"default_is_code,omitempty"`
	Required      bool            `yaml:"required,omitempty"`
	Hidden        bool            `yaml:"hidden,omitempty"`
	Warning       string          `yaml:"-"` // Used for comments
}

func (ManifestFlag) MarshalYAML

func (f ManifestFlag) MarshalYAML() (any, error)

type ManifestHelp

type ManifestHelp struct {
	Type         string `yaml:"type,omitempty"`
	SlackChannel string `yaml:"slack_channel,omitempty"`
	SlackTeam    string `yaml:"slack_team,omitempty"`
	TeamsChannel string `yaml:"teams_channel,omitempty"`
	TeamsTeam    string `yaml:"teams_team,omitempty"`
}

type ManifestProperties

type ManifestProperties struct {
	Name        string            `yaml:"name"`
	Description MultilineString   `yaml:"description"`
	Features    []ManifestFeature `yaml:"features"`
	Help        ManifestHelp      `yaml:"help,omitempty"`
}

type ManifestReleaseSource

type ManifestReleaseSource struct {
	Type  string `yaml:"type"`
	Host  string `yaml:"host"`
	Owner string `yaml:"owner"`
	Repo  string `yaml:"repo"`
}

type ManifestVersion

type ManifestVersion struct {
	GoToolBase string `yaml:"gtb"`
}

type MultilineString

type MultilineString string

func (MultilineString) MarshalYAML

func (s MultilineString) MarshalYAML() (any, error)

type SkeletonConfig

type SkeletonConfig struct {
	Name         string
	Repo         string
	Host         string
	Description  string
	Path         string
	GoVersion    string // overrides autodetected version when set
	Features     []ManifestFeature
	HelpType     string // "slack", "teams", or ""
	SlackChannel string
	SlackTeam    string
	TeamsChannel string
	TeamsTeam    string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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