config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: MIT Imports: 6 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 {
	Templates struct {
		Commit    string `json:"commit" yaml:"commit" validate:"required"`
		Changelog string `json:"changelog" yaml:"changelog" validate:"-"`
	} `json:"templates" yaml:"templates"`
	Args []struct {
		Name     string   `json:"name,omitempty" yaml:"name" validate:"required"`
		Options  []Option `json:"options,omitempty" yaml:"options" validate:"-"`
		Required bool     `json:"required,omitempty" yaml:"required,omitempty" validate:"-"`
		Width    int      `json:"width,omitempty" yaml:"width" validate:"omitempty,gte=0"`
	} `json:"args,omitempty" yaml:"args" validate:"gt=0"`
}

Config contains structure of configuration file.

func NewFromFile

func NewFromFile(path string) (*Config, error)

NewFromFile returns configuration from file with given path.

func (*Config) RequiredArgs

func (c *Config) RequiredArgs() (r []string)

type Decoder

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

Decoder decodes app's configuration from file.

Supported extensions: - yaml, yml - json

func NewDecoder

func NewDecoder(filename string) *Decoder

NewDecoder creates new decoder that decodes configuration file.

func (*Decoder) Decode

func (d *Decoder) Decode(v any) error

Decode configuration from file into value.

type Option

type Option struct {
	Value       string `json:"value" yaml:"value" validate:"required"`
	Description string `json:"description" yaml:"description" validate:""`
	Version     string `json:"version" yaml:"version" validate:"oneof=major minor patch"`
}

Option is an option for selection prompt where value fills provided in template field and version specifies its impact on semver version.

func (Option) Doc

func (o Option) Doc() string

Field implements selectable option field documentation.

func (Option) Field

func (o Option) Field() string

Field implements selectable option field.

Jump to

Keyboard shortcuts

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