args

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Flag

func Flag[T any](r argers.Reader, target *T, value T, short, long string) argers.Reader

Flag adds a flag to the given reader.

When the flag by the short name (e.g. `-v`) or long name (e.g. `--verbose`) is in the arguments, the given target will be assigned to the given value, otherwise the target is not modified. Flags may be grouped in the arguments (e.g. `-bvf`).

The returned reader is the same as the given reader.

func Named

func Named[T utils.ParsableConstraint](r argers.Reader, target *T, short, long string) argers.Reader

Named adds a named value with a value to the given reader.

When the named value by the short name (e.g. `-o file.txt`) or long name (e.g. `--out file.txt`) is in the arguments, the given target will be assigned to the value of the following argument. Flags must be the last in a group (e.g. `-vo file.txt`) or not in a group.

The returned reader is the same as the given reader.

func New

func New() argers.Reader

New creates a new argument reader.

func Optional

func Optional[T utils.ParsableConstraint](r argers.Reader, target *T) argers.Reader

Optional adds an optional argument to the given reader.

After all the flags, named values, and positional arguments are read, any remaining arguments will be set to the given optional in the order that they were added. Optional arguments may only be added after positional arguments and may not be used with variant arguments. The given target is set to the given argument at its position.

The returned reader is the same as the given reader.

func Pos

func Pos[T utils.ParsableConstraint](r argers.Reader, target *T) argers.Reader

Pos adds a positional argument to the given reader.

After all the flags and named values have been removed, the remaining arguments are read in order where the first added positional argument then the next positional and so on. The given target is set to the given argument at its position.

The returned reader is the same as the given reader.

func Var

func Var[T utils.ParsableConstraint, S ~[]T](r argers.Reader, target *S) argers.Reader

Var adds a variant argument to the given reader.

After all the flags, named values, and positional arguments are read, any remaining arguments will be set to this variant argument. Only one variant may be added and it may only be added after positional arguments. This may not be used with optional arguments. The target is set to the given arguments.

The returned reader is the same as the given reader.

Types

This section is empty.

Jump to

Keyboard shortcuts

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