modinfo

package
v0.0.0-...-cca5969 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package modinfo has been designed to interpretate modinfo.lua and give access to the supported values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InterfaceToString

func InterfaceToString(value interface{}) string

InterfaceToString returns a string representation of the provided interface.

Types

type ConfigurationOptions

type ConfigurationOptions struct {
	// Values holds a list of all existing options.
	Values []Option
}

ConfigurationOptions represents "configuration_options" in modinfo.lua.

func NewConfigurationOptions

func NewConfigurationOptions() *ConfigurationOptions

NewConfigurationOptions creates a new ConfigurationOptions instance.

type Controller

type Controller interface {
	FieldByName(string) *Field
	Load(string) error
}

Controller is the interface that wraps the ModInfo methods.

type Field

type Field struct {
	// Name is the original global name like "name", "description", "api_version",
	// etc.
	Name string

	// Description is the global description in a human-friendly format. It could
	// be used to  describe what the global does in a short form.
	Description string

	// Value holds the original global value.
	Value interface{}

	// IsRequired marks whether the global is required to be in modinfo.lua.
	IsRequired bool
}

Field represents a single global in modinfo.lua.

func NewField

func NewField(name, description string, isRequired bool) *Field

NewField creates a new Field instance.

func (*Field) String

func (g *Field) String() string

String returns a string representation of a Field value which is its value.

type ModInfo

type ModInfo struct {
	// General holds a map of all general fields. It includes all the required
	// ones except compatibility ones.
	General map[string]*Field

	// Compatibility holds a map of all required compatibility fields.
	Compatibility map[string]*Field

	// ConfigurationOptions holds "configuration_options".
	ConfigurationOptions *ConfigurationOptions

	// Other holds all other fields that are not required.
	Other map[string]*Field
	// contains filtered or unexported fields
}

ModInfo represents modinfo.lua data.

func New

func New() *ModInfo

New creates a new ModInfo instance.

func (*ModInfo) FieldByName

func (m *ModInfo) FieldByName(name string) (*Field, error)

FieldByName returns a single Field based on its original global name.

func (*ModInfo) FieldsByName

func (m *ModInfo) FieldsByName(names []string) (result []*Field, err error)

FieldsByName returns multiple Field structs based on the provided global names.

func (*ModInfo) Load

func (m *ModInfo) Load(path string) error

Load loads modinfo.lua files from the provided path and sets all the supported values.

type Option

type Option struct {
	// Label is the original label value.
	//
	// configuration_options.<option>.label
	Label string

	// Name is the original name value.
	//
	// configuration_options.<option>.name
	Name string

	// Default is the original default value.
	//
	// configuration_options.<option>.default
	Default *OptionDefault

	// Default is the original hover value.
	//
	// configuration_options.<option>.hover
	Hover string
}

Option represents a single option for "configuration_options" in modinfo.lua.

func NewOption

func NewOption() *Option

NewOption creates a new Option instance.

type OptionDefault

type OptionDefault struct {
	// Description is the original description value.
	//
	// configuration_options.<option>.default.description
	Description string

	// Description is the original data value.
	//
	// configuration_options.<option>.default.data
	Data interface{}
}

OptionDefault represents an option default value.

func (*OptionDefault) DataString

func (c *OptionDefault) DataString() string

DataString returns a string representation of an OptionDefault data.

func (*OptionDefault) String

func (c *OptionDefault) String() string

String returns a string representation of a OptionDefault value which is its description.

Jump to

Keyboard shortcuts

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