pkg

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Our configs for parsing and building
	ExportFile   string
	ConfigStruct string
	Package      string
	Version      string
	DryRun       bool
	ShowVersion  bool
	ShowHelp     bool

	// Wrappers for env configs
	RequiredIfNoDef       bool
	UseFieldNameByDefault bool
	Prefix                string
	TagName               string

	*flag.FlagSet
}

Config handles all the envexample configurations.

func NewConfig

func NewConfig(args []string) (*Config, error)

NewConfig will load a config from CLI flags.

func (*Config) Validate

func (c *Config) Validate() error

Validate will check if the config is an actual valid set of configurations.

func (*Config) Writer

func (c *Config) Writer() (io.WriteCloser, error)

Writer will create the proper io.Writer based on the configuration. Be sure to close the writer when done.

type EnvTagOptions added in v0.1.0

type EnvTagOptions struct {
	Key string

	LoadFile bool
	Unset    bool
	NotEmpty bool
	Required bool

	IsSlice         bool
	SliceSeperator  string
	DefaultValueTag string

	TypeName string
	Prefix   string
}

func NewEnvTagOptions added in v0.1.0

func NewEnvTagOptions(name string, gen *Generator, isSlice bool, tag string) *EnvTagOptions

func (*EnvTagOptions) DefaultValue added in v0.1.0

func (opt *EnvTagOptions) DefaultValue() string

func (*EnvTagOptions) LinePrefix added in v0.1.0

func (opt *EnvTagOptions) LinePrefix() string

type Generator added in v0.1.0

type Generator struct {
	RequiredIfNoDef       bool
	UseFieldNameByDefault bool
	TagName               string
	// contains filtered or unexported fields
}

func NewGenerator added in v0.1.0

func NewGenerator(cfg *Config) (*Generator, error)

func (*Generator) Run added in v0.1.0

func (g *Generator) Run(writer io.Writer) error

func (*Generator) WriteField added in v0.1.0

func (g *Generator) WriteField(writer io.Writer, field types.Member, prefix string)

func (*Generator) WriteStruct added in v0.1.0

func (g *Generator) WriteStruct(writer io.Writer, entry *StructQueueEntry)

type StructQueueEntry added in v0.1.0

type StructQueueEntry struct {
	TypeName  types.Name
	FieldDocs []string
	Prefix    string
}

Jump to

Keyboard shortcuts

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