derive

package
v0.0.0-...-250c7b9 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlagType = "-"
	KeyType  = "@"
	PosType  = "#"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Argument

type Argument struct {
	Name       string // name of the struct-field
	Deriver    string // name of the Deriver implementation for the Argument
	Identifier string // identifier for the Argument
	Alias      string // (not implemented) single character alias for the Argument (only valid for Flag/KeyValue)
	Default    string // the default value for the Argument
	Type       string // indicates the type of Argument
	Required   bool   // indicates if the Argument is required
	Repeatable bool   // indicates the Argument is repeatable

	// Index of the Arg
	//
	// Only specified for non-repeatable PositionalArg
	Index int

	// Index of the start of the Arg
	//
	// Only specified for repeatable PositionalArg
	IndexFrom int

	// Usage/description of the Arg
	Usage string
	// contains filtered or unexported fields
}

An Argument represents a clap.Arg defined via struct-tags.

func (*Argument) Field

func (a *Argument) Field() any

Field returns a pointer to the underlying variable for the Argument.

func (*Argument) Pos

func (a *Argument) Pos() int

type Program

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

A Program represents a structure with a number of Argument that can be automatically derived and parsed into clap.Arg in order to be parsed.

func Parse

func Parse(input any) (*Program, error)

Parse a struct into a *Program.

func (*Program) Args

func (p *Program) Args() []*Argument

Args returns the *Argument in the order they are defined in the struct.

func (*Program) Decode

func (p *Program) Decode(input any) error

Decode some input type and attempt to derive a number of *Argument from struct-tags and fields.

Jump to

Keyboard shortcuts

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