options

package
v0.9.13 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2022 License: MIT Imports: 1 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HeaderOption

type HeaderOption struct {
	// Exact row number of column name definition at a worksheet.
	// Default: 1.
	Namerow int32
	// Exact row number of column type definition at a worksheet.
	// Default: 2.
	Typerow int32
	// Exact row number of column note at a worksheet.
	// Default: 3.
	Noterow int32
	// Start row number of data at a worksheet.
	// Default: 4.
	Datarow int32

	// The line number of column name definition in a cell.
	// Value 0 means the whole cell.
	// Default: 0.
	Nameline int32
	// The line number of column type definition in a cell.
	// Value 0 means the whole cell.
	// Default: 0.
	Typeline int32
}

type InputOption

type InputOption struct {
	// Only for protogen: input file formats.
	// Note: recognize all formats (Excel, CSV, and XML) if not set (value is nil).
	// Default: nil.
	Formats []format.Format
	// - For protogen, specify only these subdirs (relative to input dir) to be processed.
	// - For confgen, specify only these subdirs (relative to workbook name option in .proto file).
	Subdirs []string
	// - For protogen, rewrite subdir path (relative to input dir).
	// - For confgen, rewrite subdir path (relative to workbook name option in .proto file).
	SubdirRewrites map[string]string
}

type Option

type Option func(*Options)

Option is the functional option type.

func Header(o *HeaderOption) Option

Header sets HeaderOption.

func ImportPaths added in v0.9.12

func ImportPaths(importPaths ...string) Option

ImportPaths specifies the paths used to search for dependencies that are referenced in import statements in proto source files. If no import paths are provided then "." (current directory) is assumed to be the only import path.

func Imports

func Imports(imports ...string) Option

Imports sets common proto files to be imported.

func Input

func Input(o *InputOption) Option

Input sets InputOption.

func InputFormats added in v0.9.7

func InputFormats(formats ...format.Format) Option

InputFormats sets input formats.

func InputSubdirs added in v0.9.7

func InputSubdirs(subdirs ...string) Option

InputSubdirs sets input subdirs.

func LocationName

func LocationName(o string) Option

LocationName sets LocationName.

func LogLevel

func LogLevel(level string) Option

LogLevel sets LogLevel.

func Output

func Output(o *OutputOption) Option

Output sets OutputOption.

func OutputFormats added in v0.9.10

func OutputFormats(formats ...format.Format) Option

OutputFormats sets output formats.

func Workbook

func Workbook(wb string) Option

Workbook sets workbook filename.

func Worksheet

func Worksheet(ws string) Option

Worksheet sets worksheet name.

type Options

type Options struct {
	// Location represents the collection of time offsets in use in a geographical area.
	// Default: "Asia/Shanghai".
	LocationName string
	LogLevel     string        // Log level: debug, info, warn, error. Default: "info".
	Header       *HeaderOption // Header options of worksheet file.
	Input        *InputOption  // Input options.
	Output       *OutputOption // Output options.
	ImportPaths  []string      // Import paths. Default: nil.
	Imports      []string      // Import common proto files. Default: nil.
	Workbook     string        // Workbook filename. Default: "".
	Worksheet    string        // Worksheet name. Default: "".
}

Options is the wrapper of tableau params. Options follow the design of Functional Options (https://github.com/tmrts/go-patterns/blob/master/idiom/functional-options.md).

func NewDefault added in v0.9.7

func NewDefault() *Options

NewDefault returns a default Options.

func ParseOptions

func ParseOptions(setters ...Option) *Options

ParseOptions parses functional options and merge them to default Options.

type OutputOption

type OutputOption struct {
	// Only for protogen: dir separator `/` or `\`  in filename is replaced by "__".
	// Default: true.
	FilenameWithSubdirPrefix bool
	// Only for protogen: append the suffix to filename.
	// Default: "".
	FilenameSuffix string
	// Only for confgen: output filename as snake_case, default is CamelCase as the protobuf message name.
	// Default: false.
	FilenameAsSnakeCase bool
	// Only for confgen: output file formats.
	// Note: Output all formats (JSON, Text, and Wire) if not set (value is nil).
	// Default: nil.
	Formats []format.Format
	// Only for confgen: output pretty format, with multiline and indent.
	// Default: true.
	Pretty bool
	// EmitUnpopulated specifies whether to emit unpopulated fields. It does not
	// emit unpopulated oneof fields or unpopulated extension fields.
	// The JSON value emitted for unpopulated fields are as follows:
	//  ╔═══════╤════════════════════════════╗
	//  ║ JSON  │ Protobuf field             ║
	//  ╠═══════╪════════════════════════════╣
	//  ║ false │ proto3 boolean fields      ║
	//  ║ 0     │ proto3 numeric fields      ║
	//  ║ ""    │ proto3 string/bytes fields ║
	//  ║ null  │ proto2 scalar fields       ║
	//  ║ null  │ message fields             ║
	//  ║ []    │ list fields                ║
	//  ║ {}    │ map fields                 ║
	//  ╚═══════╧════════════════════════════╝
	//
	// Default: true.
	EmitUnpopulated bool
}

Jump to

Keyboard shortcuts

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