file

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: MIT Imports: 8 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoFile = fmt.Errorf("file: no file")

ErrNoFile is an returned by Lookup implementation to report that lookup didn't find any file to parse.

Functions

This section is empty.

Types

type BytesLookup

type BytesLookup []byte

BytesLookup succeeds source lookup with itself.

func (BytesLookup) Lookup

func (b BytesLookup) Lookup() (io.ReadCloser, error)

Lookup implements Lookup interface.

type FlagLookup

type FlagLookup struct {
	FlagSet *flag.FlagSet
	Name    string
}

FlagLookup search for flag with equal name and interprets it as filename to open.

func LookupFlag added in v0.3.0

func LookupFlag(fs *flag.FlagSet, name string) *FlagLookup

LookupFlag is a shortcut to build up a FlagLookup structure.

func (*FlagLookup) Lookup

func (f *FlagLookup) Lookup() (io.ReadCloser, error)

Lookup implements Lookup interface.

type Lookup

type Lookup interface {
	Lookup() (io.ReadCloser, error)
}

Lookup is an interface to search for syntax source.

type LookupFunc

type LookupFunc func() (io.ReadCloser, error)

LookupFunc is an adapter that allows the use of ordinar functions as Lookup.

func (LookupFunc) Lookup

func (f LookupFunc) Lookup() (io.ReadCloser, error)

Lookup implements Lookup interface.

type MultiLookup

type MultiLookup []Lookup

MultiLookup holds Lookup implementations and their order.

func (MultiLookup) Lookup

func (ls MultiLookup) Lookup() (io.ReadCloser, error)

Lookup implements Lookup interface.

type Parser

type Parser struct {
	// Lookup contains logic of how configuration source must be opened.
	// Lookup must not be nil.
	Lookup Lookup

	// Requires makes Parser to fail if Lookup doesn't return any source.
	Required bool

	// Syntax contains logic of parsing source.
	Syntax Syntax
}

Parser contains options of parsing source and filling flag values.

func (*Parser) Parse

func (p *Parser) Parse(_ context.Context, fs parse.FlagSet) error

Parse implements flagutil.Parser interface.

type PathLookup

type PathLookup string

PathLookup prepares source search on a path. If path is not exits it doesn't fail.

func (PathLookup) Lookup

func (p PathLookup) Lookup() (io.ReadCloser, error)

Lookup implements Lookup interface.

type Syntax

type Syntax interface {
	Unmarshal([]byte) (map[string]interface{}, error)
}

Syntax is an interface capable to parse file syntax.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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