arg

package
v0.0.0-...-9bc5058 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RequiredArgumentMissing is used when a required argument is missing.
	RequiredArgumentMissing = iota

	// InsufficientArguments is used when at least one greedy argument is required.
	InsufficientArguments

	// InvalidArgument is used when an invalid input is used for an argument.
	InvalidArgument
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Argument

type Argument struct {
	Parser Parser

	Name        string
	Constraints string

	Greedy   bool
	Required bool
}

Argument is information about an argument and how to process it.

func (*Argument) DisplayName

func (arg *Argument) DisplayName() string

DisplayName is the user friendly appearance of an argument.

type ParsedArguments

type ParsedArguments = map[string]interface{}

ParsedArguments is a map of arguments using the name of the argument as the key.

func Parse

func Parse(args []*Argument, rawArgs []string) (ParsedArguments, error)

Parse parses the raw arguments into a map.

type Parser

type Parser func(arg *Argument, rawArg string) (interface{}, error)

Parser takes a raw argument string and outputs an interface for use.

type ParsingError

type ParsingError struct {
	ErrorType int
	// contains filtered or unexported fields
}

ParsingError is an error in argument transformation.

func NewParsingError

func NewParsingError(arg *Argument, errorType int) *ParsingError

NewParsingError creates an argument parsing error that's user friendly.

func (*ParsingError) Error

func (err *ParsingError) Error() string

func (*ParsingError) UIError

func (err *ParsingError) UIError() string

UIError is an error string suitable for sending to the user.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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