flagfile

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2023 License: BlueOak-1.0.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigFlag

func ConfigFlag(fs *flag.FlagSet) flag.Value

ConfigFlag returns a flag.Value which, when set, parses fs with a config file read from the set file path. The default (zero-value) parser config is used.

func Parse

func Parse(r io.Reader, fs *flag.FlagSet) (err error)

Parse uses the default Parser to parse an io.Reader for configuration of a flag.FlagSet. The reader must contain newline-delimited name=value pairs for each set flag. Comments begin at any # or ; character and whitespace is trimmed. INI section headers (in the form [Section Name]) and empty lines are ignored.

Types

type Error

type Error struct {
	File string
	Line int
	Err  error
}

Error reports the filename and line number where parsing errors occurred.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type Parser

type Parser struct {
	// AllowUnknown specifies whether Parse should skip unknown flag errors,
	// or return these errors to the caller.
	AllowUnknown bool

	// ParseSections specifies whether to parse INI sections (in the form
	// [Section Name]).  By default, INI section headers are ignored.
	ParseSections bool
}

Parser provides parsing of INI-like config files to modify values in a flag.FlagSet. Parser behavior is configured by its struct fields.

func (*Parser) ConfigFlag

func (p *Parser) ConfigFlag(fs *flag.FlagSet) flag.Value

ConfigFlag returns a flag.Value which, when set, parses fs with a config file read from the set file path. Parse options are specified through p.

func (*Parser) Parse

func (p *Parser) Parse(r io.Reader, fs *flag.FlagSet) (err error)

Parse parses an io.Reader for configuration of a flag.FlagSet. The reader must contain newline-delimited name=value pairs for each set flag. Comments begin at any # or ; character and whitespace is trimmed.

Jump to

Keyboard shortcuts

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