flarg

package
v0.0.0-...-24dab48 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2015 License: MIT Imports: 7 Imported by: 0

README

Flarg

Flag argument processing for running programs derived from go-arg

Documentation

Overview

Package flarg parses command line arguments using the fields from a struct. derived from: https://github.com/alexflint/go-arg

Index

Constants

This section is empty.

Variables

View Source
var (
	NoPointer          = Xrror("%s is not a pointer (did you forget an ampersand?)").Out
	NoStructPointer    = Xrror("%T is not a struct pointer").Out
	UnsupportedField   = Xrror("%s.%s: %s fields are not supported").Out
	LongShortArguments = Xrror("%s.%s: short arguments must be one character only").Out
	UnrecognizedTag    = Xrror("unrecognized tag '%s' on field %s").Out
)
View Source
var (
	ProcessError    = Xrror("error processing %s: %v").Out
	UnknownArgument = Xrror("unknown argument %s").Out
	MissingValue    = Xrror("missing value for %s").Out
	Required        = Xrror("%s is required").Out
	PositionalError = Xrror("too many positional arguments at '%s'").Out
)
View Source
var (
	NotExported = Xrror("%v field is not exported").Out
	NotScalar   = Xrror("not a scalar type: %s").Out
)
View Source
var InvalidArg = Xrror("%s is not a valid argument").Out
View Source
var Unwritable = Xrror("%v field is not writable").Out

Functions

func MustParse

func MustParse(dest interface{}, exclude ...string)

MustParse processes command line arguments and exits upon failure

func Parse

func Parse(dest interface{}, exclude ...string) error

Parse processes command line arguments and stores them in dest

func Xrror

func Xrror(err string) *flargError

Types

type Parser

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

Parser represents a set of command line options with destination values

func New

func New(dest interface{}, exclude ...string) (*Parser, error)

NewParser constructs a parser from a list of destination structs

func (*Parser) Fail

func (p *Parser) Fail(msg string)

Fail prints usage information to stdout and exits with non-zero status

func (*Parser) Help

func (p *Parser) Help(w io.Writer)

Help writes the usage string of the provided []*spec followed by the full help string for each option

func (*Parser) Parse

func (p *Parser) Parse(args []string) (bool, error)

Parse processes the given command line option, storing the results in the field of the structs from which NewParser was constructed

func (*Parser) Usage

func (p *Parser) Usage(w io.Writer)

Usage writes usage information of the provided []*spec to the given writer

Jump to

Keyboard shortcuts

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