parser

package
v0.0.0-...-4b2efa1 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CfgKey

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

type CfgKeys

type CfgKeys []*CfgKey

type CmdParser

type CmdParser struct {
	*ENVParser
	// contains filtered or unexported fields
}

*

  • Parse command from cli into configuration struct

type ENVParser

type ENVParser struct {
	*FlagsParser
	// contains filtered or unexported fields
}

*

  • Parse env into configuration struct

type FileParser

type FileParser struct {
	*CmdParser
}

* * Parse toml file into configuration struct. * If the value comes from cli, use the cli value, * Otherwise, override it.

type FlagsParser

type FlagsParser struct {
	FlagSets MatrixFlagSets

	RenderGeneratorConfigFunc func(*viper.Viper, engine.GeneratorConfig, bool, ...viper.DecoderConfigOption) (interface{}, error)
	RenderWriterConfigFunc    func(*viper.Viper, engine.WriterConfig, bool, ...viper.DecoderConfigOption) (interface{}, error)
	RenderBenchmarkConfigFunc func(*viper.Viper, engine.BenchmarkConfig, bool, ...viper.DecoderConfigOption) (interface{}, error)

	GetGeneratorDefaultFlagsFunc func(engine.GeneratorConfig) (*pflag.FlagSet, interface{})
	GetWriterDefaultFlagsFunc    func(engine.WriterConfig) (*pflag.FlagSet, interface{})
	GetBenchmarkDefaultFlagsFunc func(engine.BenchmarkConfig) (*pflag.FlagSet, interface{})
	// contains filtered or unexported fields
}

*

  • Parse cli flags into configuration struct.
  • Print usage info
  • Print configuration struct into toml

func (*FlagsParser) InitBenchmarkFlagSet

func (parser *FlagsParser) InitBenchmarkFlagSet(cfg *engine.BenchmarkConfig) (*pflag.FlagSet, []MatrixFlagSet)

func (*FlagsParser) InitGeneratorFlagSet

func (parser *FlagsParser) InitGeneratorFlagSet(cfg *engine.GeneratorConfig) (*pflag.FlagSet, []MatrixFlagSet)

func (*FlagsParser) InitWriterFlagSet

func (parser *FlagsParser) InitWriterFlagSet(cfg *engine.WriterConfig) (*pflag.FlagSet, []MatrixFlagSet)

func (*FlagsParser) Print

func (parser *FlagsParser) Print() error

Print current command line flags in toml format

func (*FlagsParser) Usage

func (parser *FlagsParser) Usage()

prints help info

type MatrixFlagSet

type MatrixFlagSet struct {
	Label  string
	FSet   *pflag.FlagSet
	SubSet MatrixFlagSets
}

type MatrixFlagSets

type MatrixFlagSets []MatrixFlagSet

type Parser

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

func New

func New(cfg *engine.Config) *Parser

func (*Parser) Parse

func (parser *Parser) Parse()

Parse command line flags first, then fill env into config secondary, if a --config <file> is given Will read from the config file and override config fields except those arguments listed in the command line. After then, all configuration info is extracted to the cfg struct

Jump to

Keyboard shortcuts

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