config

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddIdentifierInitialism

func AddIdentifierInitialism(s ...string)

AddIdentifierInitialism is used to add custom initializations into the library.

func HandlePresets added in v1.0.1

func HandlePresets(preset string, c *Config) error

HandlePresets is used to set defaults before fields are read in from the config.

func Validate

func Validate(c *Config) error

Validate attempts to validate the given config for errors

Types

type Cases

type Cases struct {
	Pascal    bool `json:"pascal,omitempty" mapstructure:"pascal,omitempty" yaml:"pascal,omitempty" toml:"pascal,omitempty"`
	Camel     bool `json:"camel,omitempty" mapstructure:"camel,omitempty" yaml:"camel,omitempty" toml:"camel,omitempty"`
	Screaming bool `json:"screaming,omitempty" mapstructure:"screaming,omitempty" yaml:"screaming,omitempty" toml:"screaming,omitempty"`
	Command   bool `json:"command,omitempty" mapstructure:"command,omitempty" yaml:"command,omitempty" toml:"command,omitempty"`
	Dotted    bool `json:"dotted,omitempty" mapstructure:"dotted,omitempty" yaml:"dotted,omitempty" toml:"dotted,omitempty"`
	Train     bool `json:"train,omitempty" mapstructure:"train,omitempty" yaml:"train,omitempty" toml:"train,omitempty"`
}

Cases holds the configuration options to what casing generation should be enabled.

type CodeValues

type CodeValues struct {
	GRPC   *int `json:"grpc,omitempty" mapstructure:"grpc,omitempty" yaml:"grpc,omitempty" toml:"grpc,omitempty"`
	YARPC  *int `json:"yarpc,omitempty" mapstructure:"yarpc,omitempty" yaml:"yarpc,omitempty" toml:"yarpc,omitempty"`
	HTTP   *int `json:"http,omitempty" mapstructure:"http,omitempty" yaml:"http,omitempty" toml:"http,omitempty"`
	Errno  *int `json:"errno,omitempty" mapstructure:"errno,omitempty" yaml:"errno,omitempty" toml:"errno,omitempty"`
	OSExit *int `json:"os_exit,omitempty" mapstructure:"os_exit,omitempty" yaml:"os_exit,omitempty" toml:"os_exit,omitempty"`
}

CodeValues holds user supplied values for Code Responders to use.

type Codes

type Codes struct {
	GRPC     bool       `json:"grpc,omitempty" mapstructure:"grpc,omitempty" yaml:"grpc,omitempty" toml:"grpc,omitempty"`
	YARPC    bool       `json:"yarpc,omitempty" mapstructure:"yarpc,omitempty" yaml:"yarpc,omitempty" toml:"yarpc,omitempty"`
	HTTP     bool       `json:"http,omitempty" mapstructure:"http,omitempty" yaml:"http,omitempty" toml:"http,omitempty"`
	Errno    bool       `json:"errno,omitempty" mapstructure:"errno,omitempty" yaml:"errno,omitempty" toml:"errno,omitempty"`
	OSExit   bool       `json:"os_exit,omitempty" mapstructure:"os_exit,omitempty" yaml:"os_exit,omitempty" toml:"os_exit,omitempty"`
	Defaults CodeValues `json:"defaults,omitempty" mapstructure:"defaults,omitempty" yaml:"defaults,omitempty" toml:"defaults,omitempty"`
}

Codes holds the configuration options relating to what Responder implementations to generate.

type Config

type Config struct {
	Opts        Options     `json:"opts,omitempty" mapstructure:"opts,omitempty" yaml:"opts,omitempty" toml:"opts,omitempty"`
	Output      *Output     `json:"output,omitempty" mapstructure:"output,omitempty" yaml:"output,omitempty" toml:"output,omitempty"`
	Go          *Go         `json:"go,omitempty" mapstructure:"go,omitempty" yaml:"go,omitempty" toml:"go,omitempty"`
	Initialisms Initialisms `json:"initialisms,omitempty" mapstructure:"initialisms,omitempty" yaml:"initialisms,omitempty" toml:"initialisms,omitempty"`
	Presets     Presets     `json:"presets,omitempty" mapstructure:"presets,omitempty" yaml:"presets,omitempty" toml:"presets,omitempty"`
	Plugins     Plugins     `json:"plugins,omitempty" mapstructure:"plugins,omitempty" yaml:"plugins,omitempty" toml:"plugins,omitempty"`
	Values      []*Element  `json:"values,omitempty" mapstructure:"values,omitempty" yaml:"values,omitempty" toml:"values,omitempty" validate:"gt=0"`
	// contains filtered or unexported fields
}

Config holds the primary configuration for the renum code generator.

func NewEmptyConfig

func NewEmptyConfig() *Config

NewEmptyConfig creates a new empty renum configuration object.

func (*Config) EnumID

func (c *Config) EnumID() string

EnumID returns the name of the enum's Go type alias in PascalCase.

func (*Config) Namespace

func (c *Config) Namespace() string

Namespace returns the renum codegenerated package namespace.

func (*Config) OutputFilename

func (c *Config) OutputFilename() string

OutputFilename returns the name of the destination's filename to use.

func (*Config) Version

func (c *Config) Version() string

Version returns the Renum version string for this configuration.

type Element

type Element struct {
	Name        string     `json:"name,omitempty" mapstructure:"name,omitempty" yaml:"name,omitempty" toml:"name,omitempty" validate:"required"`
	Message     string     `json:"message,omitempty" mapstructure:"message,omitempty" yaml:"message,omitempty" toml:"message,omitempty"`
	Comment     string     `json:"comment,omitempty" mapstructure:"comment,omitempty" yaml:"comment,omitempty" toml:"comment,omitempty"`
	Description string     `json:"description,omitempty" mapstructure:"description,omitempty" yaml:"description,omitempty" toml:"description,omitempty"`
	Codes       CodeValues `json:"codes,omitempty" mapstructure:"codes,omitempty" yaml:"codes,omitempty" toml:"codes,omitempty"`
	Ident       Identifier `json:"-" yaml:"-" toml:"-" mapstructure:"-"`
	Value       int        `json:"-" yaml:"-" toml:"-" mapstructure:"-"`
	Config      *Config    `json:"-" yaml:"-" toml:"-" mapstructure:"-"`
	// contains filtered or unexported fields
}

Element represents a single, unique value within an enum that's being generated.

func (Element) Camel

func (e Element) Camel() string

Camel returns the enum's name in camelCase form.

func (Element) Command

func (e Element) Command() string

Command returns the enums name in command-case form.

func (Element) Dotted

func (e Element) Dotted() string

Dotted returns the enum's name in dotted.case form.

func (Element) HTTPCode

func (e Element) HTTPCode() int

HTTPCode is a template helper function that returns the enum element's HTTP Status code. That value is determined by order of priority: explicitly set in config, default set in config, and finally, the built in default. (520)

func (Element) OSExitCode

func (e Element) OSExitCode() int

OSExitCode is a template helper function that returns the enum element's OS Exit code. That value is determined by order of priority: explicitly set in config, default set in config, and finally, the built in default. (1)

func (Element) Pascal

func (e Element) Pascal() string

Pascal returns the enum's name in PascalCase form.

func (Element) Prefixed

func (e Element) Prefixed() Identifier

Prefixed returns an identifier for the element with the enum type prefix attached.

func (Element) PrefixedPascal

func (e Element) PrefixedPascal() string

PrefixedPascal is a template function that returns the a qualified name with the enum's type as a prefix (PascalCase).

func (Element) PrefixedScreaming

func (e Element) PrefixedScreaming() string

PrefixedScreaming is a template function that returns the a qualified name with the enum's type as a prefix (SCREAMING_CASE).

func (Element) PrefixedSnake

func (e Element) PrefixedSnake() string

PrefixedSnake is a template function that returns the a qualified name with the enum's type as a prefix (snake_case).

func (Element) Screaming

func (e Element) Screaming() string

Screaming returns the enum's name in SCREAMING_CASE form.

func (Element) Snake

func (e Element) Snake() string

Snake returns the enum's name in snake_case form.

func (Element) Train

func (e Element) Train() string

Train returns the enum's name in TRAIN-CASE form.

func (Element) YARPCCode

func (e Element) YARPCCode() int

YARPCCode is a template helper function that returns the enum element's YARPC error code. That value is determined by order of priority: explicitly set in config, default set in config, and finally, the built in default. (2)

type Go

type Go struct {
	Type    *GoType    `json:"type,omitempty" mapstructure:"type,omitempty" yaml:"type,omitempty" toml:"type,omitempty"`
	Build   *GoBuild   `json:"build,omitempty" mapstructure:"build,omitempty" yaml:"build,omitempty" toml:"build,omitempty"`
	Package *GoPackage `json:"package,omitempty" mapstructure:"package,omitempty" yaml:"package,omitempty" toml:"package,omitempty"`
}

Go holds the configuration for Go related enum generation settings.

type GoBuild

type GoBuild struct {
	Tags string `json:"tags,omitempty" mapstructure:"tags,omitempty" yaml:"tags,omitempty" toml:"tags,omitempty"`
}

GoBuild is a placeholder for Go build tags.

type GoPackage

type GoPackage struct {
	Name string `json:"name,omitempty" mapstructure:"name,omitempty" yaml:"name,omitempty" toml:"name,omitempty" validate:"required"`
	Path string `json:"path,omitempty" mapstructure:"path,omitempty" yaml:"path,omitempty" toml:"path,omitempty"`
}

GoPackage holds configuration details about the parent Go package that code will be generated for.

type GoType

type GoType struct {
	Numeric     string `` /* 206-byte string literal not displayed */
	Name        string `json:"name,omitempty" mapstructure:"name,omitempty" yaml:"name,omitempty" toml:"name,omitempty" validate:"required"`
	Comment     string `json:"comment,omitempty" mapstructure:"comment,omitempty" yaml:"comment,omitempty" toml:"comment,omitempty"`
	SkipDeclare bool   `` /* 127-byte string literal not displayed */
	// contains filtered or unexported fields
}

GoType is a sub-configuration for holding information about the enum's Go type alias, and it's declaration.

func (*GoType) Prefix

func (g *GoType) Prefix() Identifier

Prefix returns an Identifier for the enum's Go type alias in a normalized form.

type Identifier

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

Identifier is used to create various cases and pluralities of the enums being generated.

func NewIdentifier

func NewIdentifier(s string) Identifier

NewIdentifier creates a new identifier from a provided string.

func (Identifier) Camel

func (i Identifier) Camel() string

Camel returns the identifiers camelCase representation.

func (Identifier) Command

func (i Identifier) Command() string

Command returns the identifiers command-case representation.

func (Identifier) Dotted

func (i Identifier) Dotted() string

Dotted returns the identifiers dotted.case representation.

func (Identifier) Ident

func (i Identifier) Ident() flect.Ident

Ident returns the identifiers underlying flect structure.

func (Identifier) Pascal

func (i Identifier) Pascal() string

Pascal returns the identifiers PascalCase representation.

func (Identifier) Screaming

func (i Identifier) Screaming() string

Screaming returns the identifiers SCREAMING_CASE representation.

func (Identifier) Snake

func (i Identifier) Snake() string

Snake returns the identifier's snake_case representation.

func (Identifier) Train

func (i Identifier) Train() string

Train returns the identifiers TRAIN-CASE representation.

type Initialisms

type Initialisms []string

Initialisms is a type alias for a slice of strings that is used to create capitalization identifiers for strings used.

type Options added in v1.0.1

type Options struct {
	Strict bool `json:"strict,omitempty" mapstructure:"strict,omitempty" yaml:"strict,omitempty" toml:"strict,omitempty" default:"true"`
}

Options is a configuration container that is used to hold some various flags surrounding the execution of renum.

type Output

type Output struct {
	Dir       string `json:"dir,omitempty" mapstructure:"dir,omitempty" yaml:"dir,omitempty" toml:"dir,omitempty" validate:"required,dir"`
	Filename  string `json:"filename,omitempty" mapstructure:"filename,omitempty" yaml:"filename,omitempty" toml:"filename,omitempty"`
	Overwrite bool   `json:"overwrite,omitempty" mapstructure:"overwrite,omitempty" yaml:"overwrite,omitempty" toml:"overwrite,omitempty"`
}

Output holds the configuration details about where to write the generated code.

type Plugins

type Plugins struct {
	Renum       Renum       `json:"renum,omitempty" mapstructure:"renum,omitempty" yaml:"renum,omitempty" toml:"renum,omitempty"`
	Cases       Cases       `json:"cases,omitempty" mapstructure:"cases,omitempty" yaml:"cases,omitempty" toml:"cases,omitempty"`
	Serializers Serializers `json:"serializers,omitempty" mapstructure:"serializers,omitempty" yaml:"serializers,omitempty" toml:"serializers,omitempty"`
	Codes       Codes       `json:"codes,omitempty" mapstructure:"codes,omitempty" yaml:"codes,omitempty" toml:"codes,omitempty"`
}

Plugins is a container structure that holds all the configuration settings for what codegen plugins should be used by the renum generator.

type Presets

type Presets struct {
	Use string `` /* 153-byte string literal not displayed */
}

Presets holds a configuration stanza for allowing users to define a preset group of settings.

type Renum

type Renum struct {
	Namespacer    bool `json:"namespacer,omitempty" mapstructure:"namespacer,omitempty" yaml:"namespacer,omitempty" toml:"namespacer,omitempty"`
	Sourcer       bool `json:"sourcer,omitempty" mapstructure:"sourcer,omitempty" yaml:"sourcer,omitempty" toml:"sourcer,omitempty"`
	Typer         bool `json:"typer,omitempty" mapstructure:"typer,omitempty" yaml:"typer,omitempty" toml:"typer,omitempty"`
	Coder         bool `json:"coder,omitempty" mapstructure:"coder,omitempty" yaml:"coder,omitempty" toml:"coder,omitempty"`
	Descriptioner bool `` /* 131-byte string literal not displayed */
	Caser         bool `json:"caser,omitempty" mapstructure:"caser,omitempty" yaml:"caser,omitempty" toml:"caser,omitempty"`
	Error         bool `json:"error,omitempty" mapstructure:"error,omitempty" yaml:"error,omitempty" toml:"error,omitempty"`
}

Renum holds configuration options about what renum interface types to implement.

type Serializers

type Serializers struct {
	Text   bool `json:"text,omitempty" mapstructure:"text,omitempty" yaml:"text,omitempty" toml:"text,omitempty"`
	JSON   bool `json:"json,omitempty" mapstructure:"json,omitempty" yaml:"json,omitempty" toml:"json,omitempty"`
	YAML   bool `json:"yaml,omitempty" mapstructure:"yaml,omitempty" yaml:"yaml,omitempty" toml:"yaml,omitempty"`
	CSV    bool `json:"csv,omitempty" mapstructure:"csv,omitempty" yaml:"csv,omitempty" toml:"csv,omitempty"`
	SQL    bool `json:"sql,omitempty" mapstructure:"sql,omitempty" yaml:"sql,omitempty" toml:"sql,omitempty"`
	Gob    bool `json:"gob,omitempty" mapstructure:"gob,omitempty" yaml:"gob,omitempty" toml:"gob,omitempty"`
	Binary bool `json:"binary,omitempty" mapstructure:"binary,omitempty" yaml:"binary,omitempty" toml:"binary,omitempty"`
	Flags  bool `json:"flags,omitempty" mapstructure:"flags,omitempty" yaml:"flags,omitempty" toml:"flags,omitempty"`
}

Serializers holds information about which serializers should be generated by the renum generator.

Jump to

Keyboard shortcuts

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