argument

package
v0.0.0-...-fdaedd9 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2018 License: MIT Imports: 3 Imported by: 3

Documentation

Overview

Package argument provides small set of types to parse and interpret command line arguments

Package argument provides small set of types to parse and interpret command line arguments

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Long

func Long(arg string) bool

Long return true given the arg is a long one

func LongTrim

func LongTrim(arg string) (string, string)

LongTrim returns the argument without it's long prefix and his target value if he has one

func Short

func Short(arg string) bool

Short return true given the arg is a short one

func ShortTrim

func ShortTrim(arg string) string

ShortTrim returns the argument without it's short prefix

Types

type Type

type Type uint8

Type defines the type of an argument

const (
	// Bool is the flag value of type bool
	Bool Type = iota
	// Int is the flag value of type int
	Int
	// String is the flag value of type string
	String
	// Float is the flag value of type float
	Float
)

func (Type) String

func (t Type) String() string

String returns the type in an outputted format

type Value

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

Value can hold any argument of type argument.Type

func NewValue

func NewValue(arg string, t Type) *Value

NewValue takes a command line string argument and his desired type and returns a new Value that can convert to t Type

func (Value) Bool

func (v Value) Bool() bool

Bool returns the value as type bool

func (Value) Float

func (v Value) Float() float64

Float returns the value as type float64

func (Value) Int

func (v Value) Int() int

Int returns the value as type int

func (*Value) Parse

func (v *Value) Parse() error

Parse parses the value as a given t Type given if the value is not a valid t Type it will return an error

func (Value) String

func (v Value) String() string

String returns the value as type string

Jump to

Keyboard shortcuts

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