flagutil

package
v0.6.18 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2022 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseArgs

func ParseArgs(command string, data interface{}, args []string) ([]string, error)

ParseArgs parses flags and args from a command string

func ParseArgsWithValueModifier

func ParseArgsWithValueModifier(command string, data interface{}, args []string, argumentModFunc ArgumentModFunc) ([]string, error)

ParseArgsWithValueModifier parses flags and args from a command string; it accepts an optional argumentModFunc which is called before each flag value is parsed, and allows one to change the value. if the flag value

Types

type ArgumentModFunc

type ArgumentModFunc func(flagName string, opt *flags.Option, flagVal *string) (*string, error)

ArgumentModFunc accepts a flagName which corresponds to the long flag name, and a pointer to a flag value. The pointer is nil if no flag was given. the function returns a new pointer set to nil if one wants to pretend as if no value was given, or a pointer to a new value which will be parsed. Note: this was created to allow passing --no-cache=$SOME_VALUE; where we must expand $SOME_VALUE into a true/false value before it is parsed. If this feature is used extensively, then it might be time to completely fork go-flags with a version where we can include control over expansion struct tags.

Jump to

Keyboard shortcuts

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