gen

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2023 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package gen contains the internals of the cgen application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTemplate

func NewTemplate() (*template.Template, error)

NewTemplate parses and initializes the embedded templates.

func RootRun

func RootRun(_ *cobra.Command, args []string, flags RootFlags) error

RootRun is the "cgen" command.

Types

type Command

type Command struct {
	Meta              meta
	IsRoot            bool
	Name              string
	Fullname          string
	Use               string    `yaml:"use"`
	Short             string    `yaml:"short"`
	Long              string    `yaml:"long"`
	Example           string    `yaml:"example"`
	Aliases           []string  `yaml:"aliases"`
	Flags             bool      `yaml:"flags"`
	Args              string    `yaml:"args"`
	NoRun             bool      `yaml:"norun"`
	PersistentPreRun  bool      `yaml:"persistent_pre_run"`
	PersistentPostRun bool      `yaml:"persistent_post_run"`
	PreRun            bool      `yaml:"pre_run"`
	PostRun           bool      `yaml:"post_run"`
	Commands          []Command `yaml:"commands"`
}

Command represents a cobra.Command with additional meta-data to be used during template execution.

func ParseCommand

func ParseCommand(file string) (*Command, error)

ParseCommand parses a yaml spec file and return the command.

func (*Command) Configure

func (c *Command) Configure(pkg, imp string)

Configure traverses c and populates all the meta data to prepare for template execution.

func (*Command) ForAll

func (c *Command) ForAll(f func(*Command))

ForAll executed f on c and all its sub-commands.

type RootFlags

type RootFlags struct {
	OutputFile string
	StubsFile  string
	Package    string
	Import     string
}

RootFlags belong to the Root command.

func (*RootFlags) Bind

func (f *RootFlags) Bind(cmd *cobra.Command)

Bind binds f to the cobra.Command.

Jump to

Keyboard shortcuts

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