gen

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DeviceTemplateName = "devices"
	ValueTemplateName  = "values"
	KeysTemplateName   = "keys"
)
View Source
const (
	LibraryName = "confMQTT"

	ConfFolder    = ""
	EntriesFolder = "confEntry"
	DevicesFolder = "confDevice"

	KeysFileName    = "keys_gen.go"
	ValuesFileName  = "values_gen.go"
	DevicesFileName = "devices_gen.go"
)

Variables

View Source
var (
	//go:embed templates/keys.go.tmpl
	KeyTemplate string
	//go:embed templates/devices.go.tmpl
	DeviceTemplate string
	//go:embed templates/values.go.tmpl
	ValueTemplate string
	//go:embed templates/header.go.tmpl
	HeaderTemplate string
	//go:embed templates/object.go.tmpl
	ObjectTemplate string

	//go:embed definitions/devices.json
	DeviceList []byte
	//go:embed definitions/keys.json
	KeyList []byte
	//go:embed definitions/values.json
	ValueList []byte
)
View Source
var (
	BasePackage        = path.Join(LibraryName, "pkg")
	InternalPackage    = path.Join(LibraryName, "internal", "pkg")
	JsonHelpersPackage = path.Join(InternalPackage, "tools")
	EntriesPackage     = path.Join(BasePackage, ConfFolder, EntriesFolder)
	DevicesPackage     = path.Join(BasePackage, ConfFolder, DevicesFolder)

	KeysPath    = filepath.Join("pkg", EntriesFolder, KeysFileName)
	ValuesPath  = filepath.Join("pkg", EntriesFolder, ValuesFileName)
	DevicesPath = filepath.Join("pkg", DevicesFolder, DevicesFileName)
)
View Source
var (
	Devices = Data[ObjectOptions]{
		PackageName: DevicesFolder,
		Imports: []string{
			EntriesPackage,
			JsonHelpersPackage,
		},
	}
)
View Source
var (
	Keys = Data[KeyOptions]{
		PackageName: EntriesFolder,
		Imports: []string{
			JsonHelpersPackage,
		},
	}
)
View Source
var (
	Template *template.Template
)
View Source
var (
	Values = Data[ObjectOptions]{
		PackageName: EntriesFolder,
		Imports: []string{
			JsonHelpersPackage,
		},
	}
)

Functions

func IsValue

func IsValue(s string) bool

func RecreateDir

func RecreateDir(dirname string)

func WriteTemplate

func WriteTemplate(filename string, templateName string, data any)

Types

type Data

type Data[T any] struct {
	PackageName string
	Imports     []string
	Values      []T
}

type KeyOptions

type KeyOptions struct {
	TypeName  string
	LongName  string
	ShortName string

	Optional bool

	Type1 string
	Type2 string
	BiVal bool

	Def     bool
	DefType string
	DefVal  string
}

func GetKey

func GetKey(s string) *KeyOptions

type ObjectOptions

type ObjectOptions struct {
	Name     string
	TypeName string
	Keys     []string
}

Jump to

Keyboard shortcuts

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