config

package
v2.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ValidChars filter = func(current, previous string) bool {
		return vailCharRegexp.MatchString(current)
	}

	In = func(chars ...string) filter {
		return func(current, previous string) bool {
			for _, char := range chars {
				if char == current {
					return true
				}
			}
			return false
		}
	}

	Not = func(cf filter) filter {
		return func(current, previous string) bool {
			return !cf(current, previous)
		}
	}
)

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	Source string     `json:"source"`
	Body   Directives `json:"body"`
}

func Config

func Config(body ...*Directive) *Configuration

func MustParse

func MustParse(filename string) *Configuration

func MustParseBytes

func MustParseBytes(bs []byte) *Configuration

func MustParseIO

func MustParseIO(reader io.Reader) *Configuration

func Parse

func Parse(filename string) (cfg *Configuration, err error)

func ParseBytes

func ParseBytes(bs []byte) (cfg *Configuration, err error)

func ParseIO

func ParseIO(reader io.Reader) (cfg *Configuration, err error)

func (*Configuration) Pretty

func (cfg *Configuration) Pretty(colorize ...bool) string

type Directive

type Directive struct {
	Line    int        `json:"line"`
	Virtual Virtual    `json:"virtual,omitempty"`
	Name    string     `json:"name"`
	Args    []string   `json:"args,omitempty"`
	Body    Directives `json:"body,omitempty"`
}

func Body

func Body(name string, body ...*Directive) *Directive

func New

func New(name string, args ...string) *Directive

func (*Directive) AddArgs

func (d *Directive) AddArgs(args ...string) *Directive

func (*Directive) AddBody

func (d *Directive) AddBody(name string, args ...string) *Directive

func (*Directive) AddBodyDirective

func (d *Directive) AddBodyDirective(directives ...*Directive)

func (Directive) Clone

func (d Directive) Clone() *Directive

func (*Directive) Pretty

func (d *Directive) Pretty(prefix int, colorize ...bool) string

func (*Directive) String

func (d *Directive) String() string

type Directives

type Directives []*Directive

func (*Directives) Append

func (ds *Directives) Append(d *Directive)

func (Directives) Clone

func (ds Directives) Clone() Directives

func (*Directives) Get

func (ds *Directives) Get(name string) *Directive

func (*Directives) Gets

func (ds *Directives) Gets(name string) (ret []*Directive)

func (Directives) Index

func (ds Directives) Index(idx int) *Directive

func (*Directives) Insert

func (ds *Directives) Insert(d *Directive, idx int)

func (Directives) Names

func (ds Directives) Names() []string

type Virtual

type Virtual string
var Include Virtual = "include"

Jump to

Keyboard shortcuts

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