plugin

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFlags

func AddFlags(groupName string, longDescription string, data interface{})

AddFlags should be used by embedded modules to inject custom flags into `yab`. It adds a set of custom flags with heading `groupName`.

The `data` argument should be a pointer to a struct with one field for each command line flag. Each field should use tags like `description` to inform the parser of metadata about the flag. (tags are the same as supported by github.com/jessevdk/go-flags)

type foo struct {
	Bar string `long:"bar" description:"Sets the 'bar' value."`
}

AddFlags("Foo Options", "", &foo{})

This would inject a custom flag group that looks like:

Foo Options
	--bar	Sets the 'bar' value.

In order to retrieve the mutated results of the set flag, users of AddFlags() should retain a reference to the `data` object and check its values after parsing is complete.

func AddToParser

func AddToParser(p Parser) error

AddToParser adds all registered flags to the passed Parser. This operation is not atomic, flags are applied on a best-effort basis (not "all-or-nothing") Returns a slice of errors indicating which flags groups failed to be added.

Types

type Parser

type Parser interface {
	// AddFlagGroup adds an additional flag group to process during parsing.
	AddFlagGroup(groupName, longDescription string, data interface{}) error
}

Parser is any object that can add flag groups to itself before performing its parse.

Jump to

Keyboard shortcuts

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